题目传送门
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
const int INF = 0x3f3f3f3f;
int Max, Min = INF;
int b[N]; //计数数组
bool IsPrime(int n) {
if (n < 2) return false;
for (int i = 2; i <= n / i; i++)
if (n % i == 0) return false;
return true;
}
int main() {
string s;
cin >> s;
//计数 s[i] - 'a':映射坐标
for (int i = 0; i < s.size(); i++) b[s[i] - 'a']++;
//扫描一遍计数数组,统计最小值与最大值,注意判断一下0个的问题
for (int i = 0; i < 26; i++) {
Max = max(Max, b[i]);
if (b[i] > 0) Min = min(Min, b[i]);
}
if (IsPrime(Max - Min)) printf("Lucky Word\n%d", Max - Min);
else printf("No Answer\n%d", 0);
return 0;
}