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)
提交記錄:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/260672.html
標籤:其他
上一篇:數字圖片的特征提取
下一篇:洛谷P2006 趙神牛的游戲
