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")

nyoj 204-Coin Test (python count)的更多相关文章

  1. nyoj 241-字母统计 (python count)

    241-字母统计 内存限制:64MB 时间限制:3000ms 特判: No 通过数:12 提交数:14 难度:1 题目描述: 现在给你一个由小写字母组成字符串,要你找出字符串中出现次数最多的字母,如果 ...

  2. python count函数

    描述 Python count() 方法用于统计字符串里某个字符出现的次数.可选参数为在字符串搜索的开始与结束位置. 语法 count()方法语法: str.count(sub, start= 0,e ...

  3. python count()

    count() 描述 Python count() 方法用于统计字符串里某个字符出现的次数.可选参数为在字符串搜索的开始与结束位置. 语法 count()方法语法: str.count(sub, st ...

  4. Python Count函数的应用

    Python Count函数的应用 通过LeetCode Origin:https://leetcode-cn.com/problems/robot-return-to-origin/ 学会了Pyth ...

  5. nyoj 268-荷兰国旗问题 (count)

    268-荷兰国旗问题 内存限制:64MB 时间限制:3000ms 特判: No 通过数:15 提交数:20 难度:1 题目描述: 荷兰国旗有三横条块构成,自上到下的三条块颜色依次为红.白.蓝.现有若干 ...

  6. python count()函数

    Python 元组 count() 方法用于统计某个元素在元祖,列表,字符串中出现的次数.可选参数为在字符串搜索的开始与结束位置. 参数 sub -- 搜索的子字符串 start -- 字符串开始搜索 ...

  7. python Count类(转)

    1.collections模块 collections模块自Python 2.4版本开始被引入,包含了dict.set.list.tuple以外的一些特殊的容器类型,分别是: OrderedDict类 ...

  8. Python count() 方法

    描述 count() 方法用于统计字符串中某个子字符串出现的次数,可选参数为开始搜索与结束搜索的位置索引. 语法 count() 方法语法: S.count(sub[,start=0[,end=len ...

  9. nyoj 517-最小公倍数 (python range(start, end) range(length))

    517-最小公倍数 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:11 难度:3 题目描述: 为什么1小时有60分钟,而不是100分钟呢?这是历史上的习惯导致. 但也并 ...

随机推荐

  1. ‎Cocos2d-x 学习笔记(26) 从源码学习 DrawCall 的降低方法

    [Cocos2d-x]学习笔记目录 本文链接:https://www.cnblogs.com/deepcho/cocos2dx-drawcall-glcalls 1. 屏幕左下角 我们通常在Cocos ...

  2. 使用Docker搭建apache环境

    Docker搭建apache环境 前言 操作机:ubuntu16 x64 Dockers servion 18.09.7 下载镜像 使用docker pull 拉取最新的 apache镜像 命令:do ...

  3. Spring Boot项目如何同时支持HTTP和HTTPS协议

    如今,企业级应用程序的常见场景是同时支持HTTP和HTTPS两种协议,这篇文章考虑如何让Spring Boot应用程序同时支持HTTP和HTTPS两种协议. 准备 为了使用HTTPS连接器,需要生成一 ...

  4. linux 中more、less 和 most 的区别

    如果你是一个 Linux 方面的新手,你可能会在 more.less.most 这三个命令行工具之间产生疑惑.在本文当中,我会对这三个命令行工具进行对比,以及展示它们各自在 Linux 中的一些使用例 ...

  5. 百万年薪python之路 -- 函数的动态参数

    1.函数的动态参数 1.1 动态接收位置参数 在参数位置用*表示接受任意参数 def eat(*args): print('我想吃',args) eat('蒸羊羔','蒸熊掌','蒸鹿尾儿','烧花鸭 ...

  6. GridSplitter

    <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <Colum ...

  7. Linux安装h2数据库

    安装H2数据库,为后面mybatisplus3J集成做铺垫 下载jar包 https://pan.baidu.com/s/1tPZQH5tum1CheDxumcN24g 运行jar包 [root@to ...

  8. flask插件之flask_session会话机制

    flask-session是flask框架的session组件,由于原来flask内置session使用签名cookie保存,该组件则将支持session保存到多个地方,如: redis:保存数据的一 ...

  9. 2018.8.2 python中is和==的区别

    一.is 和==的区别 1.is 比较的是左右两边的内存地址, ==比较的是左右两边的值. 2.id() 通过id()可以查看一个变量表示的值得内存中的地址. s = 'alex' s1 = 'ale ...

  10. 10、pytest -- skip和xfail标记

    目录 1. 跳过测试用例的执行 1.1. @pytest.mark.skip装饰器 1.2. pytest.skip方法 1.3. @pytest.mark.skipif装饰器 1.4. pytest ...