1071 小赌怡情 (15 分) python

2021/10/28 22:09:32

本文主要是介绍1071 小赌怡情 (15 分) python,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1071 小赌怡情 (15 分)

money, n = map(int, input().split())
for _ in range(n):
    #money为0的判断放在输入前,否则测试点4不过,应考虑玩家一开始的筹码为0的情况
    if money == 0:
        print('Game Over.')
        break
    info = list(map(int, input().split()))
#     if money == 0:    #错误写法
#         print('Game Over.')
#         break
    if info[2] > money:
        print('Not enough tokens.  Total = ' + str(money) + '.')
    elif (info[0] < info[-1] and info[1] == 1) or (info[0] > info[-1] and info[1] == 0):
        money += info[2]
        print("Win "+ str(info[2]) + '!  Total = ' + str(money) + '.')
    else:
        money -= info[2]
        print("Lose " + str(info[2]) + ".  Total = " + str(money) + '.')

    


这篇关于1071 小赌怡情 (15 分) python的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程