这里写代码片
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a[30];
string s;
int mini = 10000;
bool zhishu(int n)
{
if (n == 0 || n == 1)
return false;
if (n == 2)
return true;
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
int main()
{
cin >> s;
int len = s.size();
for (int i = 0; i < len; i++)
a[s[i] - 'a']++;
sort (a,a + 26);
int maxi = a[25];
for (int i = 0; i < 26; i++)
if (a[i] < mini && a[i] != 0)
mini = a[i];
if (zhishu(maxi - mini))
printf("Lucky Word\n%d",maxi-mini);
else
printf("No Answer\n0");
return 0;
}
欢迎使用CSDN-markdown编辑器
最新推荐文章于 2022-07-16 11:34:56 发布