1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include<bits/stdc++.h> using namespace std; char word[105]; int alphabet['z'+5],maxnum=INT_MIN,minnum=INT_MAX,prime[35]={0,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}; int main(){ freopen("word.in","r",stdin); freopen("word.out","w",stdout); scanf("%s",word); int len=strlen(word); for(int i=0;i<len;i++){ alphabet[word[i]]++; }
for(int i='a';i<='z';i++){ if(maxnum<alphabet[i]){ maxnum=alphabet[i]; } if(minnum>alphabet[i] and alphabet[i]!=0){ minnum=alphabet[i]; } } for(int i=1;i<=25;i++){ if(maxnum-minnum==prime[i]){ printf("Lucky Word\n%d",prime[i]); return 0; } } printf("No Answer\n0"); return 0; }
|