PTA 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.


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%.


For example, 3 games' odds are given as the following:


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


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.


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.


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
结尾无空行

解题思路

inputList = []
for _ in range(3):
    inputData = list(map(float,input().split()))
    # inputData = list(map(float, "1.1 2.5 1.7".split()))
    inputList.append(inputData)
retList = []
res = 1
for i in inputList:
    maxVal = max(i)
    indexVal = i.index(maxVal)
    if indexVal == 0:
        retList.append("W")
    elif indexVal == 1:
        retList.append("T")
    else:
        retList.append("L")
    res *= maxVal
res = 2 * (res*0.65 - 1)
## 难点是格式化方式
res = "%.2f" % res
retList.append(res)
print(" ".join(retList))


目录
相关文章
【PTA】7-8 到底有多二 (15分)
【PTA】7-8 到底有多二 (15分)
2223 0
|
7月前
|
C语言
pta浙大版《C语言程序设计(第3版)》 习题6-4 使用函数输出指定范围内的Fibonacci数 (20分)
pta浙大版《C语言程序设计(第3版)》 习题6-4 使用函数输出指定范围内的Fibonacci数 (20分)
|
7月前
|
测试技术 C++
【PTA】​L1-003 个位数统计​ (C++)
【PTA】​L1-003 个位数统计​ (C++)
150 0
【PTA】​L1-003 个位数统计​ (C++)
|
C++
【PAT甲级 - C++题解】1011 World Cup Betting
【PAT甲级 - C++题解】1011 World Cup Betting
61 0
PTA 7-4 胖达与盆盆奶 (20 分)
俗称“胖达”,会排队吃盆盆奶。它们能和谐吃奶的前提,是它们认为盆盆奶的分配是“公平”的,即:更胖的胖达能吃到更多的奶,等胖的胖达得吃到一样多的奶。
186 0
|
测试技术
PTA 1039 到底买不买 (20 分)
小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。
120 0
L1-057 PTA使我精神焕发 (5 分)
L1-057 PTA使我精神焕发 (5 分)
97 0
L1-057 PTA使我精神焕发 (5 分)
PTA 7-1 多二了一点 (15 分)
若一个正整数有 2n 个数位,后 n 个数位组成的数恰好比前 n 个数位组成的数多 2,则称这个数字“多二了一点”。
130 0
PTA 1088 三人行 (20 分)
子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。”
89 0