笨小猴题解
2024-10-05 19:39:41
发布于:北京
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main(){
string t;
int mx = 0,mn = 101,a[30] = {};
cin >> t;
for(int i = 0;i < t.size();i ++) a[t[i] - 97] ++;
for(int i = 0;i <= 26;i ++){
mx = max(mx,a[i]);
if(a[i] != 0) mn = min(mn,a[i]);
}
int ans = mx - mn;
if(ans < 2){
cout << "No Answer" << endl << 0;
return 0;
}
for(int i = 2;i * i <= ans;i ++){
if(ans % i == 0){
cout << "No Answer" << endl << 0;
return 0;
}
}
cout << "Lucky Word" << endl << ans;
return 0;
}
这里空空如也
有帮助,赞一个