题解
2024-08-11 16:32:24
发布于:河南
2阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int cnt[27];
int main() {
std::string str;
cin >> str;
for (int i = 0; i < str.length(); i) {
cnt[str[i] - 'a'];
}
int max, min;
max = -0x3f3f3f3f;
min = 0x3f3f3f3f;
for (int i = 0; i < 26; ++i) {
if (cnt[i] > max) {
max = cnt[i];
}
if (cnt[i] < min && cnt[i] >= 1) {
min = cnt[i];
}
}
int av = max - min;
if (av < 2) {
cout << "No Answer" << endl << '0' << endl;
exit(0);
}
if (av == 2) {
cout << "Lucky Word" << endl << av << endl;
exit(0);
}
for (int i = 3; i <= sqrt(av); ++i) {
if (av % i == 0) {
cout << "No Answer" << endl << '0' << endl;
exit(0);
}
}
cout << "Lucky Word" << endl << av << endl;
}
这里空空如也
有帮助,赞一个