2 solutions
-
0
Guest MOD
-
2
代码:
#include<bits/stdc++.h> typedef long long ll; using namespace std; const int N=10086; string a; int s[N]; int ma,mi=1e9; bool su(int n){ if(n==1||n==0) return 0; for(int i=2;i<n/i;i++){ if(n%i==0){ return 0; } } return 1; } int main(){ cin.sync_with_stdio(false); ios::sync_with_stdio(0); cin>>a; for(int i=0;i<a.size();i++){ s[a[i]-'a']++; } for(int i=0;i<26;i++){ if(s[i]!=0&&s[i]>ma) ma=s[i]; if(s[i]!=0&&s[i]<mi) mi=s[i]; } int z=ma-mi; if(su(z)){ cout<<"Lucky Word"<<'\n'<<z; } else{ cout<<"No Answer"<<'\n'<<"0"; } return 0; } -
0
#include<bits/stdc++.h> using namespace std; int a[26]; int main(){ int le=0,c=0,maxn=0,minn=110; string s; cin>>s; le=s.size(); for(int i=0;i<=le-1;i++){ c=s[i]; c[a-97]++; } int zhishu[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; for(int i=0;i<=25;i++){ if(a[i]<minn&&a[i]!=0)minn=a[i]; } for(int i=0;i<=25;i++){ if(a[i]>maxn)maxn=a[i]; } int cha=maxn-minn; for(int i=0;i<=24;i++){ if(cha==zhishu[i]){ cout<<"Lucky Word"<<endl; cout<<cha; return 0; } } cout<<"No Answer"<<endl; cout<<"0"; return 0; }
- 1
Information
- ID
- 437
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- (None)
- # Submissions
- 132
- Accepted
- 36
- Uploaded By