1 条题解

  • 0
    @ 2023-7-20 16:34:52

    简单

    已AC!

    #include <bits/stdc++.h>
    using namespace std;
    bool prime(int e)
    {
        if (e == 1) return false;
        if (e == 2 || e == 3) return true;
        if (e % 6 != 5 && e % 6 != 1) return false;
        for (int i = 2;i * i <= e;i++)
        {
            if (e % i == 0) return false;
        }
        return true;
    }
    char a[26];
    int main()
    {
        string s;
        cin >> s;
        for (int i = 0;i < s.length();i++)
        {
            int u = s[i] - 'a';
            a[u]++;
        }
        sort(a,a + 26);
        int i = 0;
        while (!a[i])
        {
            i++;
        }
        if (prime(a[25] - a[i]))
        {
            cout << "Lucky Word" << endl << a[25] - a[i];
        }
        else
        {
            cout << "No Answer" << endl << 0;
        }
    }
    
    • 1

    信息

    ID
    1018
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    17
    已通过
    13
    上传者