#include <bits/stdc++.h>
using namespace std;
bool prime(int x) {
if (x < 2)return false;
else {
for (int i=2; i<=sqrt(x); i++) {
if (x % i == 0)return false;
}
}
return true;
}
int main() {
int a[26], maxn=0, minn=1000;
string s;
memset(a, 0, sizeof(a));
cin >> s;
for (int i=0; i<s.length(); i++)a[s[i]-'a'] += 1;
for (int i=0; i<26; i++) {
if (a[i] > maxn)maxn = a[i];
if (a[i]<minn && a[i]!=0)minn = a[i];
}
if (prime(maxn-minn))cout << "Lucky Word" << endl << maxn-minn;
else cout << "No Answer" << endl << 0;
return 0;
}
P1125 [NOIP2008 提高组] 笨小猴
于 2024-09-01 10:46:28 首次发布