NYOJ 204 Coin Test

原创 2015年07月07日 17:26:32

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
int u,d;
int gcd(int a,int b)
{
if(a==0) return b;
else return gcd(b%a,a);
}
int main()
{
int n;
char c;
scanf("%d",&n);
getchar();
for(int i=0;i!=n;i++)
{
c=getchar();
if(c=='S') {puts("Bingo");return 0;}
if(c == 'U') ++u;
else ++d;
}
int g=gcd(u,u+d);
if((double)u/(u+d)-0.5>0.003 ||(double)u/(u+d)-0.5<-0.003) puts("Fail");
else printf("%d/%d",u/g,(u+d)/g);
}

                    
版权声明:转载请注明出处

nyoj204,Coin Test

//输出正面朝上的结果,如果出现一个立着的输出Bingo,正面朝上的概率小于0.003或者大于0.5的输出Fail#include #include char str[65550]; int ys(i...

NYoj 204Coin Test(化简最简小数)

Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin up an...

南阳oj 题目204 Coin Test

Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin up and...

南阳题目204-Coin Test

Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin u...

NYOJ204coin text

Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin u...

Coin Test

Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin up an...

nyoj部分ACM答案

  • 2012年11月17日 18:53
  • 502B
  • 下载

NYOJ题目 离线版

  • 2015年09月08日 19:35
  • 1.76MB
  • 下载

ATSHA204A加密芯片攻略——使用篇

ATSHA204A加密芯片是ATMEL公司研发的一款高安全性的,功能丰富的加密IC,使用SHA-256算法进行加密操作,内置16*32字节的slot(EEPROM)可以存储用户数据和秘钥,唯一的9字节...
  • a5882230
  • a5882230
  • 2016年07月17日 10:31
  • 12227

jquery图片自动轮播插件coin-slider

  • 2011年12月27日 23:11
  • 455KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:NYOJ 204 Coin Test
举报原因:
原因补充:

(最多只允许输入30个字)