nyoj.204 Coin Test【水题】 2015/03/15
2015-03-15 16:33
190 查看
Coin Test
时间限制:3000 ms | 内存限制:65535 KB难度:1
描述
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.
输入Three will be two line as input.
The first line is a number N(1<N<65536)
telling you the number of coins on the desk.
The second line is the result with N litters.The letter are "U","D",or "S","U" means the coin is on the right side. "D" means the coin is on the other side ."S" means standing on the desk.
输出If test successeded,just output the possibility of the coin on the right side.If the test failed please output "Fail",If there is one or more"S",please output "Bingo"
样例输入
6 UUUDDD
样例输出
1/2
#include<stdio.h> #include<string.h> #include<math.h> int gcd( int a,int b ){ return b?gcd(b,a%b):a; } int main(){ int n,num,i,m; double sum; char s[70000]; while(scanf("%d",&n)!=EOF){ getchar(); for( i = 0 ; i < n ; ++i ) scanf("%c",&s[i]); if( strstr(s,"S") ){ printf("Bingo\n"); continue; } num = 0 ; for( i = 0 ; i < n ; ++i ){ if( s[i] == 'U' ) num++; } sum = 1.0 * num / n; if( fabs(sum-0.5) > 0.003 ){ printf("Fail\n"); continue; } m = gcd(num,n); printf("%d/%d\n",num/m,n/m); } return 0; }
[/code]
相关文章推荐
- nyoj.25 A Famous Music Composer【水题】 2015/03/15
- nyoj.216 A problem is easy【水题】 2015/03/15
- nyoj.283 对称排序【水题】 2015/03/15
- nyoj.458 小光棍数【水题】 2015/03/15
- nyoj.484 The Famous Clock【水题】 2015/03/15
- nyoj.733 万圣节派对【水题】 2015/03/15
- HDU 5099 Comparison of Android versions(坑水题)
- hpuoj【1053】进制转换【水题】
- Poj 1442 Black Box(优先队列水题)
- 2017 Multi-University Training Contest - Team 2,HDU 6045 Is Derek lying?(思维水题)
- hdu 1233 还是畅通工程 水题~~~~~~~~~kruskal算法AC
- HDU 6066 17多校3 RXD's date(超水题)
- 一道提交过很多次才过的水题= = 回文数字
- HDU 6075 Questionnaire 水题 判奇偶
- UVA - 11995 I Can Guess the Data Structure!(水题)
- HDU5512 Pagodas(GCD+水题)
- hdu 4451 Dressing 排列组合/水题
- 【HUD 1029】Ignatius and the Princess IV(思维-水题)
- codeforces 505B Mr. Kitayuta's Colorful Graph(水题)
- ACM第二次比赛题目及标准程序(基础水题)