NYOJ204coin text
来源:互联网 发布:淘宝直播买翡翠靠谱吗 编辑:程序博客网 时间:2024/05/29 11:04
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
#include<stdio.h>#include<math.h>int gcd(int a,int b){while(b){int t=a%b;a=b;b=t;}return a;}void fun(int u,int n){double data;data=(u*1.0)/n-0.5;if(fabs(data)>0.003)printf("Fail\n");else{int t=gcd(u,n);printf("%d/%d\n",u/t,n/t);//要化到最简,所以直接除以最大公因数后再除}return ;}int main(){int n,u,d,s;char a;while(~scanf("%d",&n)){getchar();u=d=s=0;for(int i=0;i<n;i++){scanf("%c",&a);if(a=='U') u++;if(a=='D') d++;if(a=='S') s++;if(s)printf("Bingo\n");else{fun(u,n);}}}
- NYOJ204coin text
- nyoj204Coin Test
- text
- text
- text
- text
- Text
- text
- text
- text
- text
- TEXT
- text
- text
- text
- text
- .text()
- text
- UVA 1025 城市里的间谍
- CodeForces 691C Exponential notation 模拟
- c# 将byte[]数组写入文件并添加空格(回车)操作
- 简单的网络通信程序 TCP
- ubuntu16.04 更行flashplayer 插件
- NYOJ204coin text
- package-info.java文件解读
- 循环输出数据到页面
- 利用Messenger跨进程通信
- 同时使用tcp和udp回射服务器
- IntelliJ IDEA 15 配置 Tomcat8
- [CTBS]许可证过期之激活
- POJ 3421 X-factor Chains (整数分解+组合数)
- 【Qt】标准int类型输入对话框