哪儿错了????
查看原帖
哪儿错了????
1145322
HYW13618469136楼主2024/8/17 11:44
#include<bits/stdc++.h>
using namespace std;
char s[110];
int b[110];
int main()
{
	cin>>s;
	int len=strlen(s),max=0,min=1000;
	for(int i=0;i<len;i++)
	{
		b[s[i]]++;
	}
	for(int i=0;i<len;i++)
	{
		if(b[s[i]]>max)
		{
			max=b[s[i]];
		}
		else if(b[s[i]]<min)
		{
			min=b[s[i]];
		}
	}
	int v=max-min,apple=1;
	for(int i=2;i<=v-1;i++)
	{
		if(v%i==0)
		{
			apple=0;
			break;
		}
	}
	if(v<=0)
	{
		apple=0;
	}
	if(apple==1)
	{
		cout<<"Lucky Word"<<endl<<v;
		return 0;
	}
	else
	{
		cout<<"No Answer"<<endl<<"0";
		return 0;
	}
}
2024/8/17 11:44
加载中...