50分求调
查看原帖
50分求调
1452893
zhanghq2024楼主2024/11/20 20:53
#include <bits/stdc++.h>
using namespace std;

bool flag[110];
int c[27];

int main()
{
	string s;
	cin >> s;
	for(int i = 0;i<s.size();i++)
	{
		int a=s[i]-'a';
		c[a]++;
	}
	int cnt=0;
	for(int i = 1;i<=26;i++)
		if(c[i]!=0) cnt++;
	int sd = *max_element(c+1,c+cnt+1) - *min_element(c+1,c+cnt+1);
	memset(flag, true, sizeof(flag));
    flag[0] = flag[1] = false;
    for(int i = 1; i <= 101; i++)
    	if(flag[i] == true)
    		for(int j = 2; j <= 101/ i; j++)
    			flag[i * j] = false;
	if(flag[sd]) cout << "Lucky Word"<<"\n"<<sd;
	else cout << "No Answer" << "\n" << 0;
	return 0;
}
2024/11/20 20:53
加载中...