PAT A1011 World Cup Betting
Posted mrdragon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT A1011 World Cup Betting相关的知识,希望对你有一定的参考价值。
PAT A1011 World Cup Betting
题目描述:
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
参考代码:
1 /**************************************************** 2 PAT A1011 World Cup Betting 3 ****************************************************/ 4 #include <iostream> 5 #include <iomanip> 6 #include <vector> 7 8 using namespace std; 9 10 const double COINS = 2; 11 const double RATIO = 0.65; 12 const char EACH_GAME_RESULT[3] = ‘W‘, ‘T‘, ‘L‘ ; 13 14 int main() 15 double BettingInfo[3][4] = 0 ; 16 double WinnerOdd = 0; 17 vector<char> Predict(3); //收益最大时的购买策略 18 19 for (int i = 0; i < 3; ++i) 20 BettingInfo[i][0] = 0; //存储每场最大胜率 21 22 for (int j = 1; j < 4; ++j) 23 cin >> BettingInfo[i][j]; 24 if (BettingInfo[i][0] < BettingInfo[i][j]) 25 BettingInfo[i][0] = BettingInfo[i][j]; //更新最大胜率 26 Predict[i] = EACH_GAME_RESULT[j - 1]; //更细最大胜率对应位置 27 28 29 30 31 for (int i = 0; i < Predict.size(); ++i) 32 cout << Predict[i] << ‘ ‘; 33 34 35 WinnerOdd = (BettingInfo[0][0] * BettingInfo[1][0] * BettingInfo[2][0] * RATIO - 1) * COINS; 36 37 cout << setiosflags(ios::fixed) << setprecision(2) << WinnerOdd; 38 39 return 0; 40
注意事项:
无。
以上是关于PAT A1011 World Cup Betting的主要内容,如果未能解决你的问题,请参考以下文章
PAT Advanced 1011 World Cup Betting
PAT 1011 World Cup Betting 查找元素