标签:des style http io ar color os sp for
题意没弄懂,还有就是没有考虑特殊情况0,导致我贡献了7次WA,感谢茂茂的提醒
As is known to all,if you throw a coin up and let it droped on the desk there are usually three results. Yes,just believe what I say ~it can be the right side or the other side or standing on the desk, If you don‘t believe this,just try In the past there were some famous mathematicians working on this .They repeat the throwing job once again. But jacmy is a lazy boy.He is busy with dating or playing games.He have no time to throw a single coin for 100000 times. Here comes his idea,He just go bank and exchange thousands of dollars into coins and then throw then on the desk only once. The only job left for him is to count the number of coins with three conditions.
He will show you the coins on the desk to you one by one. Please tell him the possiblility of the coin on the right side as a fractional number if the possiblity between the result and 0.5 is no larger than 0.003. BE CAREFUL that even 1/2,50/100,33/66 are equal only 1/2 is accepted ! if the difference between the result and 0.5 is larger than 0.003,Please tell him "Fail".Or if you see one coin standing on the desk,just say "Bingo" any way.
6 UUUDDD
1/2
#include<stdio.h> #include<math.h> #define MAXN 100000+10 char arr[MAXN]; int i,len,a,b,c,N,t; int gcd(int a,int b) { return !b?a:gcd(b,a%b); } int main() { while(~scanf("%d",&N)){ getchar(); scanf("%s",arr); a=b=c=0; for(i=0;i<N;i++) { if(arr[i]=='U') a++; if(arr[i]=='S') c=1; } if(c==1) printf("Bingo\n"); else if(a==0) printf("0\n"); else if(fabs(a*1.0/N)>0.503) printf("Fail\n"); else { t=gcd(a,N); printf("%d/%d\n",a/t,N/t); } } return 0; }
标签:des style http io ar color os sp for
原文地址:http://blog.csdn.net/qq_16767427/article/details/41920931