P1125 80Pts 2个点WA
  • 板块灌水区
  • 楼主HypixelSkyblock
  • 当前回复4
  • 已保存回复5
  • 发布时间2024/7/12 10:40
  • 上次更新2024/7/12 11:45:30
查看原帖
P1125 80Pts 2个点WA
983008
HypixelSkyblock楼主2024/7/12 10:40

https://www.luogu.com.cn/record/162325842

#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)

2024/7/12 10:40
加载中...