题解 | #[NOIP2018]标题统计#
[NOIP2008]笨小猴
http://www.nowcoder.com/practice/17865bc2a75c4944a872ef709958c56e
#include<stdio.h>
#include<string.h>
int main()
{
char s[100], arr[100] = {0};
gets(s);
int i, j;
int max=0, min=100;
for(i=0; i<strlen(s); i++)
{
arr[s[i]-'0']++;
}
for(i=0; i<100; i++)
{
if(max < arr[i])
max = arr[i];
if(arr[i] != 0 && min > arr[i])
min = arr[i];
}
int flag=0;
for(i=2; i<max-min; i++)
{
if((max-min) % i == 0)
{
flag = 1;
break;
}
}
if(max-min == 1 || max-min == 0)
flag = 1;
if(flag == 0)
{
printf("Lucky Word\n");
printf("%d\n", max-min);
}
else
{
printf("No Answer\n");
printf("0");
}
}