50分求助,数据本地能过洛谷上过不了
查看原帖
50分求助,数据本地能过洛谷上过不了
117473
tonymarble楼主2021/8/17 15:24
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int c[27];
char w[100];
int main(){
	scanf("%s",&w);
	for(int i = 0;i < strlen(w);i++)  c[w[i] - 'a' + 1]++;
	sort(c + 1,c + 27);
	for(int i = 1;i <= 26;i++)  if(c[i]){
		if(c[26] - c[i] < 2){
			printf("No Answer\n0");
			return 0;
		}
		for(int j = 2;j <= sqrt(c[26] - c[i]);j++)  if(!((c[26] - c[i]) % j)){
			printf("No Answer\n0");
			return 0;
		}
		printf("Lucky Number\n%d",c[26] - c[i]);
		return 0;
	}
}
2021/8/17 15:24
加载中...