求助,在VS运行没问题洛谷编译错误
查看原帖
求助,在VS运行没问题洛谷编译错误
940472
Sirenaya楼主2023/9/15 22:37
 #include<iostream>
#include<string>
using namespace std;

int main()
{
	int maxn = 0, minn = 100;
	int ans = 0;
	int Alpehbet[26] = { 0 };
	string Word = " ";
	cin >> Word;
	for (int i = 0; i < size(Word); i++)
	{
		int index = 0;
		index = Word[i] - 'a' + 0;
		Alpehbet[index]++;
	}
	for (int i = 0; i < 26; i++)
	{
		if (Alpehbet[i] > maxn && Alpehbet[i] != 0)
			maxn = Alpehbet[i];
		else if (Alpehbet[i] < minn && Alpehbet[i] != 0)
			minn = Alpehbet[i];
	}
	ans = maxn - minn;
	bool flag = true;
	for (int i = 2; i < ans-1; i++)
	{
		if (ans % i == 0)
		{
			flag = false;
			break;
		}
	}
	if (flag&&ans>0)
	{
		cout << "Lucky Word"<<endl;
        cout<<ans<<endl;
	}
	else
	{
		cout << "No Answer"<<endl;
         cout<<0 <<endl;
	}
	return 0;
}
2023/9/15 22:37
加载中...