100粉福:码风

· · 个人记录

#include <bits/stdc++.h>
using namespace std;

int main(){
    freopen("word.in", "r", stdin);
    freopen("word.out", "w", stdout);
    string a;
    cin >> a;
    int ac[26] = {0};
    for(int i = 0; i < a.size(); i++){
        ac[a[i] - 97]++;
    }
    int max = 0, min = 1e9;
    for(int i = 0; i < 26; i++){
        if(ac[i] > max){
            max = ac[i];
        }
        if(ac[i] < min && ac[i] != 0){
            min = ac[i];
        }
    }
    int n = max - min;
    bool f = true;
    for(int i = 2; i < n; i++){
        if(n % i == 0){
            f = false;
        }
    }
    if(n <= 1){
        f = false;
    }
    if(f){
        cout << "Lucky Word" << endl;
        cout << n << endl;
    }else{
        cout << "No Answer" << endl;
        cout << 0 << endl;
    }
    return 0;
}

随手粘一题的代码qwq