2 solutions
-
2
#include<bits/stdc++.h> using namespace std; const int N=26; int geshu[N]; int main() { string shuru; cin>>shuru; int maxn=0,minn=100; for(int i=0;i<shuru.size();i++)geshu[shuru[i]-'a']++; for(int i=0;i<N;i++) { if(geshu[i]>maxn)maxn=geshu[i]; if(geshu[i]<minn&&geshu[i]!=0)minn=geshu[i]; } int zhishu=maxn-minn; bool chu=true; if(zhishu<2)chu=false; for(int i=2;i<zhishu;i++)if(zhishu%i==0)chu=false; if(chu==true) { cout<<"Lucky Word"<<endl<<zhishu; } else { cout<<"No Answer"<<endl<<0; } return 0; }
-
0
#include<bits/stdc++.h> using namespace std; const int N=200; int st[N]; int main() { string str; cin>>str; int minv,maxv; int len=str.size(); for(int i=0;i<len;i++) { st[str[i]]++; } for(int i=0;i<len;i++) { if(i==0||st[str[i]]>maxv) maxv=st[str[i]]; if(i==0||st[str[i]]<minv) minv=st[str[i]]; } int t=maxv-minv; bool st=true; if(t<2) { st=false; } for(int i=2;i<=t/i;i++) { if(t%i==0) { st=false; } } if(st) { cout<<"Lucky Word"<<endl; cout<<maxv-minv<<endl; }else{ cout<<"No Answer"<<endl; cout<<0<<endl; } return 0; }
- 1
Information
- ID
- 928
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 86
- Accepted
- 20
- Uploaded By