nyoj-204Coin Test
来源:互联网 发布:日本建筑风格 知乎 编辑:程序博客网 时间:2024/06/05 18: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
- 来源
- 郑州大学校赛题目
- 上传者
张云聪
import java.util.Scanner;public class Main {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubScanner input=new Scanner(System.in);int n=input.nextInt();String s=input.next();int u=0;boolean mark=false;for(int i=0;i<n;i++){if(s.charAt(i)=='U')u++;if(s.charAt(i)=='S'){mark=true;break;}}if(mark)System.out.println("Bingo");else{if(Math.abs(1.0*u/n-0.5)>0.003){System.out.println("Fail");}else{int res=GCD(u,n);System.out.println(u/res+"/"+n/res);}}}private static int GCD(int u, int n) {// TODO Auto-generated method stubint res=1;while(res!=0){res=u%n;u=n;n=res;}return u;}}
- 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--204 Coin Test【水题】
- NYOJ---题目204Coin Test
- NYoj 204Coin Test(化简最简小数)
- NYOJ - Coin Test
- NYOJ-ACM-Coin Test
- NYOJ 204 Coin Test【简单题+英文题】
- nyoj.204 Coin Test【水题】 2015/03/15
- mex
- 控件串口编程
- 收藏的blog和论坛
- 从零开始学习jQuery (十) jQueryUI常用功能实战
- 底层的CCMenu 穿透弹出框Touch事件 解决方法
- nyoj-204Coin Test
- 搜狗手机输入法
- 配置编译安装arm平台qt库qt-everywhere-opensource-src-4.8.5
- 10.3.6 TCP传输连接建立
- String类型转换为Date类型
- 从零开始学习jQuery (十一) 实战表单验证与自动完成提示插件
- 内存映射文件实现多进程通信
- 从零开始学习jQuery(剧场版) 你必须知道的javascript
- 设有一头小母牛,从出生第四年起每年生一头小母牛,按此规律,第N年时有几头母牛?