请看代码
#include<bits/stdc++.h>
using namespace std;
int s[100];
bool is_prime(int x){
if(x == 0) return 0;
if(x == 1) return 1;
if(x == 2) return 1;
for(int i = 2; i < x; i++){
if(x % i == 0){
return 0;
}
}
return 1;
}
int main(){
string a;
cin >> a;
int len = a.size();
for(int i = 0; i < len; i++){
s[a[i]-'a']++;
}
int maxn = -1;
int minn = 500;
for(int i = 0; i < 26; i++){
if(s[i] > maxn) maxn = s[i];
if(s[i] < minn && s[i] != 0) minn = s[i];
}
int c = maxn - minn;
if(is_prime(c)){
cout << "Lucky Word" << endl << c;
}
else{
cout << "No Answer" << endl << 0;
}
return 0;
}