题解 | #[NOIP2008]笨小猴#
[NOIP2008]笨小猴
https://www.nowcoder.com/practice/17865bc2a75c4944a872ef709958c56e
#include<stdio.h> #include<string.h> int main() { int maxn = 0, minn =9, sum = 0; int i, j, m,flag=1; char ch[10] ; scanf("%s", ch); for (i = 0; i < strlen(ch); i++) { sum=0; for (j = 0; j < strlen(ch); j++) { if (ch[i] == ch[j]) sum++; } if (sum > maxn) { maxn = sum; } if (sum < minn) { minn = sum; } } m = maxn - minn; for(i=2;i<m;i++) { if(m%i==0) flag=0; } if(flag==1 && m!=1 && m!=0) { printf("Lucky Word\n%d", m); } else { m = 0; printf("No Answer\n%d", m); } }#菜狗的解题#