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

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

英文看不懂,有道,谷歌翻译一下,看数据大致能懂,优秀代码推荐:

[cpp]

#include "cstdio"

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

c语言coin函数库,Coin Test | C/C++程序员之家相关推荐

  1. 构造函数为什么不能是虚函数 ( 转载自C/C++程序员之家)

    从存储空间角度,虚函数对应一个指向vtable虚函数表的指针,这大家都知道,可是这个指向vtable的指针其实是存储在对象的内存空间的.问题出来了,如果构造函数是虚的,就需要通过 vtable来调用, ...

  2. acm c语言大数问题,acm大数问题 | C/C++程序员之家

    acm:大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,我们该如何去计算它并输出它? 输入 输入一个整数 ...

  3. lancet: 一个全面、高效、可复用的go语言工具函数库

    Lancet lancet(柳叶刀)是一个全面.高效.可复用的go语言工具函数库. lancet受到了java apache common包和lodash.js的启发. 特性

  4. 基于TIA博途SCL语言的设备累计运行时间FB函数库_具体方法及程序示例

    基于TIA博途SCL语言的设备累计运行时间FB函数库_具体方法及程序示例 如下图所示,打开博途,新建一个项目,添加一个CPU,在该CPU中,添加一个FB,命名为:设备累计运行时间, 双击打开该FB,在 ...

  5. C语言数学函数库<math.h>及常用函数

    C语言数学函数库<math.h>及常用函数 一.<math.h> C语言中常用的一个数学函数库,里面涵盖了常用的数学运算,如求对数.指数.绝对值.三角函数.两数中最大数等.使用 ...

  6. python绘制函数图像opengl3d_写给 python 程序员的 OpenGL 教程

    原标题:写给 python 程序员的 OpenGL 教程 作者:牧马人 (本文来自作者投稿) 1预备知识 OpenGL 是 Open Graphics Library 的简写,意为"开放式图 ...

  7. python没有库怎么办_python缺少依赖(ImportError)库怎么办 | C/C++程序员之家

    python缺少依赖(ImportError)库怎么办?python缺少依赖(ImportError)库?ImportError: No module named setuptools,ImportE ...

  8. c语言cgi函数库,cgic: 为C语言编写CGI的C函数库

    CGIC介绍 怎样写CGIC应用程序 怎样产生图片在CGIC中? CGI调试特征: 利用捕获 cgic函数参考 cgic变量参考 cgic结果编码参考 cgic快速索引 一般的Unix系统都支持ANS ...

  9. C语言Math函数库简介

    C语言的Math库下面有很有实用的库函数,下面简单的介绍下. 1.  abs( )  --添加头文件<stdlib.h> 2.  acos( )  --反余弦函数 --参数范围(-1, 1 ...

最新文章

  1. Window对象中setInterval()和setTimeout()的区别
  2. 【BZOJ2625】[Neerc2009]Inspection 最小流
  3. 【小米笔试题】朋友圈问题-并查集解法
  4. java.lang包—StringBuffer类和StringBuilder类
  5. 新东方雅思词汇---6.1、oppose
  6. 格式说明_ISO11784/85 FDX-B动物芯片格式写码说明
  7. linux安装mysql5.5.52,Linux系统上安装MySQL 5.5prm
  8. Netty之四种常用 IO 模型
  9. 用结构化思维策划一个会议
  10. Web前端满屋花案例框架
  11. 虾皮shopee根据ID取商品详情 API 返回值说明
  12. 27 信息过滤与反垃圾
  13. 冒泡排序算法(bubbling sort)
  14. pagehelper不调用startpage依旧执行分页问题处理
  15. 干支纪年法简便算法_初中历史所涉及的四种纪年法
  16. 在Fedora 14下安装yong输入法
  17. python笔记之1-简单读入+循环、判断+数组+函数调用+题目Resistors in Parallel(18焦作)
  18. python画名字廖华兴_python第二周基本图形绘制
  19. 【ZOJ3587】Marlon's String——白四爷×KMP 白濑肆の算法完全解读KMP篇 KMP来袭第二弹前缀什么的果然最讨厌了!【1.0%达成!】
  20. onload和ready的不同

热门文章

  1. 【PCB专题】PCB 阻焊层(solder mask)与助焊层(paste mask)有什么区别
  2. Android开发中WIFI和GPRS网络的切换
  3. html查找器如何卸载,租号器要求卸载影子系统-怎么完全删除影子系统
  4. C#常见容器ArrayList、List、HashSet、Hashtable 、Dictionary、Stack、Queue
  5. Convolutional Neural Network
  6. 如何在云计算平台上完成分子对接
  7. STM32超低功耗入门之停止模式
  8. 【学神】1-15 linux启动及常见故障的排除
  9. zz 用chrome模拟各种手机
  10. 风格迁移-风格损失函数(Gram矩阵)理解