求调教,程序只输出最大值数量而并非最大值减最小值的结果
查看原帖
求调教,程序只输出最大值数量而并非最大值减最小值的结果
661595
a2lyaXNhbWUgbWFyaXNh楼主2022/7/12 09:02

rt

我们也可以像笨小猴那样做选择题(雾)

code:

#include<bits/stdc++.h>
using namespace std;
int zimu[26];
int maxx=-114514,minn=114514;
int jie;
bool f=true;
int main (){
	string word;
	cin>>word;
	const int I_MAX=word.size();
	for(int i=0; i<I_MAX; i++) {
		zimu[word[i]-'a']++;
	}
	for(int i=0; i<26; i++) {
		if(zimu[i]>maxx)maxx=zimu[i];
		if(zimu[i]<minn)minn=zimu[i];//似乎是这里出了问题 
	}
	jie=maxx-minn;
	for(int i=2; i*i<=jie; i++) {
		if(jie%i==0) {
			f=false;
			break;
		}
	}
	if(f&&jie>=2){
		cout<<"Lucky Word\n"<<jie;
	}else{
		cout<<"No Answer\n"<<0;
	}
	return 0;
}
2022/7/12 09:02
加载中...