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. xss姿势利用

    1.定位页面可以出现xss的位置 可能会出现联合点利用 一个页面多个存储位置或者一个页面多个参数联合利用 例如输入xss 查看页面源码页面里有多个xss 或者多个参数显示 可以利用 需要注意的是有的是 ...

  2. 备战双 11!蚂蚁金服万级规模 K8s 集群管理系统如何设计?

    作者 | 蚂蚁金服技术专家 沧漠 关注『阿里巴巴云原生』公众号,回复关键词"1024",可获取本文 PPT. 前言 Kubernetes 以其超前的设计理念和优秀的技术架构,在容器 ...

  3. Mac tensorflow mnist实例

    Mac tensorflow mnist实例 前期主要需要安装好tensorflow的环境,Mac 如果只涉及到CPU的版本,推荐使用pip3,傻瓜式安装,一行命令!代码使用python3. 在此附上 ...

  4. Java8系列 (六) 新的日期和时间API

    概述 在Java8之前, 我们一般都是使用 SimpleDateFormat 来解析和格式化日期时间, 但它是线程不安全的. @Test public void test() { SimpleDate ...

  5. 使用koa-mysql-session时报错

    描述 在本地测试代码没问题,但是部署到服务器上时就报错. 错误 > cross-env WEBPACK_TARGET=node NODE_ENV=production node ./server ...

  6. token和session

    什么是token? token是服务端生成的一串字符串,目的是作为客户端进行请求的一个令牌.当第一次登录后,服务器生成一个token(一串字符串),并将此token返回给客户端,此后页面接收到请求后, ...

  7. win10+MinGw+ffmpeg 编译

    一.安装MinGw+msys 下载 mingw-get-setup.exe 并安装,安装完成会弹出以下界面. 选中红色框几个选项,点击Installation->Apply Changes 进行 ...

  8. Python文件处理:创建、打开、追加、读、写

    在Python中,不需要导入外部库来读取和写入文件.Python为创建.写入和读取文件提供了内置的函数. 在本文中,我们将学习 如何创建文本文件 如何将数据附加到文件中 如何读取文件 如何逐行读取文件 ...

  9. NOIP模拟 4

    T1没开longlong T2忘了有向... T3是个好题,可以说将复杂度从N^2优化到NlogN是一个质的飞跃 考虑分治(要想出log可不就要分治么!(segtree也行 但我不会) 对于一个分治区 ...

  10. Java中打印日志,这4点很重要!

    目录 一.预先判断日志级别 二.避免无效日志打印 三.区别对待错误日志 四.保证记录完整内容 打印日志,要注意下面4点. 一.预先判断日志级别 对DEBUG.INFO级别的日志,必须使用条件输出或者使 ...