社区讨论
P1125 80Pts 2个点WA
灌水区参与者 4已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @lyi3cvrv
- 此快照首次捕获于
- 2024/07/12 10:41 2 年前
- 此快照最后确认于
- 2024/07/12 11:45 2 年前
https://www.luogu.com.cn/record/162325842
C#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n){
if(n <= 1) return false;
for (int i = 2;i <= sqrt(n);i++)
if(n % i == 0)
return false;
return true;
}
int main(){
string word;
cin >> word;
int maxn = 0, minn = INT_MAX;
map<char, int> freq;
for (char c : word) {
freq[c]++;
maxn = max(maxn, freq[c]);
minn = min(minn, freq[c]);
}
if (isPrime(maxn - minn)) {
cout << "Lucky Word" << endl;
cout << maxn - minn << endl;
} else {
cout << "No Answer" << endl;
cout << 0 << endl;
}
return 0;
}
我太弱了调了半天还是80,求大佬调,给关注(1)
回复
共 5 条回复,欢迎继续交流。
正在加载回复...