#include using namespace std; //判断是不是质数 bool isPrime(int n) { //最快的方法 if (n < 2) return false; if (n == 2 || n == 3) return true; if (n % 6 != 1 && n % 6 != 5) return false; for (int i = 5; i <= floor(sqrt(n)); i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } int main() { string str; getline(cin, str); unordered_map _map; //存入hash表 for (int i = 0; i < str.length(); ++i) { _map[str[i]]++; } //迭代找到最大和最小 unordered_map::iterator it = _map.begin(); int maxn = INT32_MIN, minn = INT32_MAX; while (it != _map.end()) { if (it->second > maxn) maxn = it->second; if (it->second < minn) minn = it->second; it++; } if (isPrime(maxn - minn)) { cout << "Lucky World" << endl; cout << maxn - minn << endl; } else { cout << "No Answer" << endl; cout << "0" << endl; } return 0; }