nyoj204,Coin Test
来源:互联网 发布:mac系统安装失败 编辑:程序博客网 时间:2024/06/18 07:38
//输出正面朝上的结果,如果出现一个立着的输出Bingo,正面朝上的概率小于0.003或者大于0.5的输出Fail
#include<stdio.h>#include<string.h>char str[65550];int ys(int x, int y){int z;for(int i = 1; i <= y; i++){if(x%i == 0 && y%i == 0){z = i;}}return z;}int main(){int n, u = 0, d = 0, s = 0;scanf("%d", &n);scanf("%s", str);int flag = 2;for(int i = 0; i < n; i++){if(str[i] == 'U'){u++;}else if(str[i] == 'D'){d++;}else if(str[i] == 'S'){//printf("Bingo\n");flag = 0;break;}}int num = ys(u, n);int a = u/num;int b = n/num;float c = float(a)/float(b);if(c < 0.003 || c > 0.5){flag = 1;}if(flag == 0) printf("Bingo\n");else if(flag == 1) printf("Fail\n");else printf("%d/%d\n", a, b);return 0;}
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
- nyoj204,Coin Test
- nyoj204
- Coin Test
- Coin Test
- Coin test
- Coin Test
- coin test
- Coin Test
- Coin Test
- Coin Test
- Coin Test
- Coin Test
- Coin Test
- NYOJ - Coin Test
- nyoj-204Coin Test
- nyoj 204-Coin Test
- NYOJ 204 Coin Test
- nyoj-204Coin Test
- JAVA中基于json串进行sql语句拼接实现select方法
- 与联想高管的谈话-do yourself
- easyui的ComboBox和DateBox复制
- JQ HTML 和 innerHTML区别
- 解决Spring MVC整合Shiro出现无法访问静态资源文件的问题
- nyoj204,Coin Test
- 使用git fetch和git rebase处理多人开发同一分支的问题
- redis操作命令记录
- CodeForces
- Tomcat
- ......
- 模版 基类 父类 指针 正确保存数据
- Python中的Numpy、SciPy、MatPlotLib安装与配置
- Redis管道简单使用及与普通方式效率对比