第四届ZZU校赛第七题 (水题) 该开始题意没看清以为是多组数据呢,多加了换行符,WA了几次,泪奔!

 1 #include<stdio.h>
2 #include<string.h>
3 #include<math.h>
4
5 int gcd(int n,int m)
6 {
7 return m==0 ? n : gcd(m,n%m);
8 }
9
10 int main()
11 {
12 int n, num_u, i, h, k;
13 char ch[65536];
14 double m;
15
16 scanf("%d",&n);
17 num_u = 0; k = 0;
18 scanf("%s",ch);
19 for (i=0; i<n; i++)
20 {
21 if(ch[i] == 'U') num_u++;
22 else if(ch[i] == 'S') k++;
23 }
24 h = gcd(n,num_u);
25 if(k != 0)
26 {
27 printf("Bingo");
28 }
29 else
30 {
31 m = fabs(num_u/(n*1.0))-0.500000;
32 if(m > (double)0.003)
33 printf("Fail");
34 else
35 printf("%d/%d",(num_u/h),(n/h));
36 }
37 return 0;
38 }
39
posted @ 2011-12-09 12:07  zhongya  阅读(140)  评论(0编辑  收藏  举报