还脑残的WA一发。。。蒻死了。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 105
char s[N];
int mn=
200,mx=
0,num[
150];
inline bool isprime(
int x){
if(x==
0||x==
1)
return 0;
for(
int i=
2;i*i<=x;++i)
if(x%i==
0)
return 0;
return 1;
}
int main(){
scanf(
"%s",s+
1);
int n=
strlen(s+
1);
for(
int i=
1;i<=n;++i) num[s[i]]++;
for(
int i=
'a';i<=
'z';++i){
if(num[i]==
0)
continue;
mx=
std::max(mx,num[i]);mn=
std::min(mn,num[i]);
}
if(isprime(mx-mn))
printf(
"Lucky Word\n%d\n",mx-mn);
else printf(
"No Answer\n0\n");
return 0;
}
转载请注明原文地址: https://www.6miu.com/read-97300.html