南阳62

 1 #include<stdio.h>
 2 char a[200];
 3 int b[200];
 4 int len(char s[])
 5 {
 6     int i=0;
 7     while(s[i]!='\0')
 8         ++i;
 9     return i;
10 }
11 int main()
12 {
13     int n,maxn,minn,i,j,t,k;
14     b[0]=b[1]=1;
15     for(i=2; i*i<200; ++i)
16         if(!b[i])
17             for(j=i*i; j<200; j+=i)
18                 b[j]=1;
19     while(~scanf("%d",&n))
20     {
21         getchar();
22         while(n--)
23         {
24             gets(a);
25             maxn=0;
26             minn=20;
27             t=len(a);
28             for(i=0; i<t; ++i)
29             {
30                 if(a[i]!=' ')
31                 {
32                     for(j=i+1,k=1; j<t; ++j)
33                         if(a[j]==a[i])
34                         {
35                             ++k;
36                             a[j]=' ';
37                         }
38                 }
39                 else
40                     continue;
41                 if(k>maxn)
42                     maxn=k;
43                 if(k<minn)
44                     minn=k;
45             }
46             if(!b[maxn-minn])
47                 printf("Lucky Word\n%d\n",maxn-minn);
48             else
49                 printf("No Answer\n0\n");
50         }
51     }
52 }
53         

 

posted @ 2016-12-28 11:36  Posase  阅读(84)  评论(0编辑  收藏  举报