(Python实现)PAT 1011 World Cup Betting (20 分)

1011 World Cup Betting (20 分)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their money where their mouths were, by laying all manner of World Cup bets.
随着2010年世界杯的继续,世界各地的球迷们变得越来越兴奋,因为来自最好球队的最好的球员正在为南非的世界杯奖杯而战斗。同样,足球迷们也在用各种方式赌世界杯,把钱花在他们说到做到的事情上。

Chinese Football Lottery provided a “Triple Winning” game. The rule of winning was simple: first select any three of the games. Then for each selected game, bet on one of the three possible results – namely W for win, T for tie, and L for lose. There was an odd assigned to each result. The winner’s odd would be the product of the three odds times 65%.
中国足球彩票提供了一种“三赢”的游戏。获胜的规则很简单:首先选择任意三个游戏。然后,对每一场选定的比赛,对三种可能的结果中的一种下注——即“W”表示赢,“T”表示平,“L”表示输。每个结果都有一个奇数。获胜者的奇数是3个奇数乘以65%的结果。

For example, 3 games’ odds are given as the following:
例如,3个游戏的赔率如下所示:

 W    T    L
1.1  2.5  1.7
1.2  3.1  1.6
4.1  1.2  1.1

To obtain the maximum profit, one must buy W for the 3rd game, T for the 2nd game, and T for the 1st game. If each bet takes 2 yuans, then the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 yuans (accurate up to 2 decimal places).
为了获得最大利润,在第三场博弈中必须购买W,在第二场博弈中必须购买T,在第一场博弈中必须购买T。如果每次下注2元,则最大收益为(4.1×3.1×2.5×65%−1)×2=39.31元(精确到小数点后2位)。

Input Specification:
Each input file contains one test case. Each case contains the betting information of 3 games. Each game occupies a line with three distinct odds corresponding to W, T and L.
每个输入文件包含一个测试用例。每个案例包含3场比赛的投注信息。每个游戏占据一行,有三个不同的赔率,分别对应“W”、“T”和“L”。

Output Specification:
For each test case, print in one line the best bet of each game, and the maximum profit accurate up to 2 decimal places. The characters and the number must be separated by one space.
对于每个测试用例,在一行中打印每个游戏的最佳赌注,最大利润精确到小数点后2位。字符和数字之间必须有一个空格。

Sample Input:

1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

Sample Output:

T T W 39.31

作者:CHEN, Yue
单位:浙江大学
代码长度限制:16 KB
时间限制:400 ms
内存限制:64 MB

解题思路:
定义一个函数,判断输出的字母以及输出的最大值,然后计算得到相应结果输出即可。

代码:

def max_num(x):
    g1 = eval(x[0])
    g2 = eval(x[1])
    g3 = eval(x[2])
    if g1 >= g2 and g1 >= g3:
        return "W", g1
    if g2 >= g1 and g2 >= g3:
        return "T", g2
    if g3 >= g1 and g3 >= g2:
        return "L", g3

if __name__ == "__main__":
    game1 = input().split()
    game2 = input().split()
    game3 = input().split()

    a, num1 = max_num(game1)
    b, num2 = max_num(game2)
    c, num3 = max_num(game3)
    num = (num1 * num2 * num3 * 0.65 - 1) * 2
    print(a + ' ' + b + ' ' + c + ' ', end="")
    print("%.2f" %num)

提交记录:
在这里插入图片描述

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Vicky__3021

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值