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) + '.')

    
上一篇:8.算法入门从零开始——找硬币——贪心


下一篇:Hive 中的函数概览