当前位置:网站首页>Openjudge: stone scissors cloth
Openjudge: stone scissors cloth
2022-07-28 05:36:00 【Programmer system】
describe
Stone scissors paper is a common guessing game . Stone is better than scissors , Scissors are better than cloth , Busson stone . If two people punch the same way , It's a draw .
One day , Small A And small B Just playing with stone scissors and paper . It's known that their fists are periodic , such as :“ stone - cloth - stone - scissors - stone - cloth - stone - scissors ……”, That is to say “ stone - cloth - stone - scissors ” For the cycle of . Excuse me, , Small A And small B Than the N After the round , Who wins more rounds ?
Input
The input contains three lines .
The first line contains three integers :N,NA,NB, They are better than N round , Small A The cycle length of the punch , Small B The cycle length of the punch .0 < N,NA,NB < 100.
The second line contains NA It's an integer , It means small A The law of punching .
The third line contains NB It's an integer , It means small B The law of punching .
among ,0 Express “ stone ”,2 Express “ scissors ”,5 Express “ cloth ”. Two adjacent integers are separated by a single space .
Output
Output one line , If small A More rounds won , Output A; If small B More rounds won , Output B; If the two are even , Output draw.
The sample input
10 3 4 0 2 5 0 5 0 2
Sample output
A
Tips
For test data , The guessing process is :
A:0 2 5 0 2 5 0 2 5 0
B:0 5 0 2 0 5 0 2 0 5
A Win. 4 round ,B Win. 2 round , The two sides are even 4 round , therefore A More rounds won .
Code
def result(a , b):
if a == b:
return 0
if a == 5 and b == 0:
return 1
if a == 0 and b == 5:
return -1
if a < b:
return 1
else:
return -1
s = input().split()
n, na, nb = int(s[0]), int(s[1]), int(s[2])
sa = input().split()
sb = input().split()
winA = winB = 0
pA = pB = 0
for i in range(n):
r = result(int(sa[pA]), int(sb[pB]))
if r == 1:
winA += 1
elif r == -1:
winB += 1
pA = (pA + 1) % na
pB = (pB + 1) % nb
if winA > winB:
print("A")
elif winA < winB:
print("B")
else:
print("draw")边栏推荐
- 子父线程交互
- 科研论文写作方法:在方法部分添加分析和讨论说明自己的贡献和不同
- 低照度图像数据集
- [singleton mode] thread safety of lazy mode
- 多线程进阶:synchronized底层原理,锁优化、锁升级的过程
- Redis' bloom filter
- URL 形式
- 多系统架构设计思考
- BeanUtils. Copyproperties cannot copy different list sets problem solving lists.transform function
- FeignClient 调用GET 方法报错 ResultVO{result=未知异常,异常详情:Request method ‘POST‘ not supported
猜你喜欢

Scope, execution process and life cycle of bean

Test Development - UI testing in automated testing

Digital twin solutions inject new momentum into the construction of chemical parks

MySQL practice 45 lectures

多线程进阶:volatile的作用以及实现原理

2022 summer practice (PowerDesigner tutorial learning record) (first week)
![[computer level 3 information security] overview of information security assurance](/img/f0/a72e61fda58ea93ca4e9db7274f6e3.png)
[computer level 3 information security] overview of information security assurance

科研论文写作方法:在方法部分添加分析和讨论说明自己的贡献和不同

Operation and use of collection framework

多模块打包:程序包:xxx不存在
随机推荐
使用深度学习训练图像时,图像太大进行切块训练预测
Digital twin solutions inject new momentum into the construction of chemical parks
C language characters and strings
List < long >, list < integer > convert each other
框架一步一步方便使用的流程
How practical is the struct module? Learn a knowledge point immediately
openjudge:判断字符串是否为回文
MySQL uses list as a parameter to query
Response < t > class
openjudge:统计数字字符个数
11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC
科研论文写作方法:在方法部分添加分析和讨论说明自己的贡献和不同
Feignclient calls the get method and reports an error resultvo{result= unknown exception. Exception details: request method 'post' not supported
2022 summer practice (first week)
Mabtis(一)框架的基本使用
Lamda gets the current number of cycles, atomicinteger
openjudge:字符串最大跨距
About localdatetime in swagger
自定义Json返回数据
List<Long>,List<Integer>互相转换