NYOJ--204 Coin Test【水题】
来源:互联网 发布:锡林浩特局气网络宾馆 编辑:程序博客网 时间:2024/05/16 12:14
Coin Test
- 描述
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"
- 样例输入
6UUUDDD
- 样例输出
1/2
<span style="font-size:12px;">#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int main(){ int n,i,m,ok,ans; char c; while(cin>>n){ ok=1;m=0; for(i=1;i<=n;++i){ cin>>c; if(c=='U') m++; else if(c=='S') ok=2; } ans=gcd(m,n); if(fabs(m*1.0/n-0.5)>0.003) ok=0; if(ok==1) printf("%d/%d\n",m/ans,n/ans); else if(ok==2) printf("Bingo\n"); else printf("Fail\n"); } return 0;}</span>
- NYOJ--204 Coin Test【水题】
- nyoj-204Coin Test
- nyoj 204-Coin Test
- NYOJ 204 Coin Test
- nyoj-204Coin Test
- nyoj 204 Coin Test
- NYOJ 204 Coin Test
- NYOJ 204 Coin Test
- NYOJ-204 Coin Test
- NYOJ 204 Coin Test
- NYOJ 204题 Coin Test
- NYOJ 题目204 Coin Test
- NYOJ---题目204Coin Test
- nyoj.204 Coin Test【水题】 2015/03/15
- NYoj 204Coin Test(化简最简小数)
- NYOJ - Coin Test
- NYOJ-ACM-Coin Test
- NYOJ 204 Coin Test【简单题+英文题】
- atitit.Windows Server 2003 2008 2012系统的新特性 attilax 总结
- atitit.自动生成数据库结构脚本,或者更换数据库,基于hibernate4
- 算法汇总
- BSP Bootloader
- 从乔布斯到库克时代,苹果发布会Keynote风格发生了哪些变化?
- NYOJ--204 Coin Test【水题】
- 【JavaScript】JavaScript基础-函数
- Mint17.1-64bit_Android开发环境配置
- bzoj 1121: [POI2008]激光发射器SZK
- 因为数据结构,我喜欢上编程
- Codeforces Round #292 (Div. 2) Problem C - Drazil and Factorial
- 算法导论2.1-4
- POJ 3187 Backward Digit Sums (dfs全排列)
- POJ 2352 Stars(树状数组 or 线段树)