204-Coin Test

内存限制:64MB
时间限制:3000ms
特判: No

通过数:2
提交数:2
难度: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

python   AC:

 def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b) n = int(input())
my_str = input()
u = my_str.count("U")
d = my_str.count("D")
s = my_str.count("S") if s >= 1:
print("Bingo")
else:
total = u + d
ans = float(u) / float(total)
if 0.497 <= ans <= 0.503:
temp = gcd(u, total)
print("%d/%d" % (u / temp, total / temp))
else:
print("Fail")

最新文章

  1. Linux shell相关
  2. 向架构师进军--&gt;可重用架构资源
  3. 数据结构算法C语言实现---序言
  4. 使用Aspose插件将程序中的表格,导出生成excel表格
  5. Java基础(35):装箱与拆箱---Java 中基本类型和包装类之间的转换(Wrapper类)
  6. MySQL页面打捞工具使用方法
  7. [RxJS + AngularJS] Sync Requests with RxJS and Angular
  8. JavaScript 之 使用 XMLHttpRequest 上传文件
  9. 从Chrome源码看浏览器如何构建DOM树
  10. python虚拟环境搭建大全(转)
  11. 使用TT模板+mvc+wcf实现简单查询
  12. 如何在VS2013中进行Boost单元测试
  13. IT桔子沙龙之本地生活服务O2O探路者笔记整理
  14. [Java 泥水匠] Java Components 之二:算法篇之项目实践中的位运算符(有你不懂的哦)
  15. 元素的属性:client系列,scroll系列,offset系
  16. win10下搭建storm环境
  17. Consul+upsync+Nginx实现动态负载均衡 摘自https://blog.csdn.net/qq_29247945/article/details/80787014
  18. 恺撒密码 I Python实现
  19. WebSocket 时时双向数据,前后端(聊天室)
  20. 微信小程序 tp5上传图片

热门文章

  1. LeetCode初级算法--排序和搜索01:第一个错误的版本
  2. kubernetes kubelet组件中cgroup的层层&quot;戒备&quot;
  3. textbox获取焦点选中内容
  4. 钢铁B2B电商案例:供应链金融如何解决供应链金融痛点
  5. 使用 git bisect 定位你的 BUG
  6. javascript获取坐标/滚动/宽高/距离
  7. Java并发编程之线程池的使用
  8. int和string的相互装换 (c++)
  9. Swagger解决你手写API接口文档的痛
  10. Python 中用面向对象的思想处理网页翻页 (初级)