5 solutions
-
1
季总发的题解有语法错误,大家看我的
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int n=s.size(); int max=1,min=1000,x=0,q=n; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(i==j) { continue; } if(s[i]==s[j]) x++; //if(s[i]==s[j]) q--; } if(x>=max) { max=x; } if(x<=min) { min=x; } q=n; x=0; } int y=max-min; int t=0; for(int i=1;i<=y;i++) { if(y%i==0) { t++; } } if(t==2) { cout<<"Lucky Word"<<endl; cout<<y; return 0; } else if(t!=2) { cout<<"No Answer"<<endl; cout<<"0"; } return 0; }
Information
- ID
- 928
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 130
- Accepted
- 29
- Uploaded By