1071 小赌怡情 满分(15 分)
常言道“小赌怡情”。这是一个很简单的小游戏:首先由计算机给出第一个整数;然后玩家下注赌第二个整数将会比第一个数大还是小;玩家下注 t 个筹码后,计算机给出第二个数。若玩家猜对了,则系统奖励玩家 t 个筹码;否则扣除玩家 t 个筹码。
题目里面的内容就不再重复废话```直接代码分析
作者: CHEN, Yue
单位: 浙江大学
时间限制: 400 ms
内存限制: 64 MB
代码长度限制: 16 KB
# 这道题一开始用break,后来发现不对
# break是跳出当前循环,题目要求的是直接结束程序,所以要用exit()
# chips, n = [int(i) for i in input().split()]
# 使用map更快
chips, n = map(int,input().split())
for i in range(n):
# 使用map更快
# n1, b, t, n2 = [int(i) for i in input().split()]
n1,b,t,n2 = map(int,input().split())
把
if t > chips:
print('Not enough tokens. Total = %s.' % chips)
else:
if (b == 1 and n1 < n2) or (b == 0 and n1 > n2):
chips += t
print('Win {}! Total = {}.'.format(t, chips))
else:
chips -= t
print('Lose {}. Total = {}.'.format(t, chips))
if chips == 0:
print('Game Over.')
exit()