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 }

注意事项:

  无。

原文地址:https://www.cnblogs.com/mrdragon/p/11399950.html

时间: 2024-11-08 12:27:58

PAT A1011 World Cup Betting的相关文章

PAT A1011 World Cup Betting(20)

AC代码 #include <cstdio> #include <algorithm> const int max_n = 3; using namespace std; /* struct Bet { double W, T, L }bet[3]; void init() { for(int i = 0; i < max_n; i++) { bet[i].W = bet[i].T = bet[i].L = 0.0; } } */ int main() { #ifdef ON

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

PAT 1011 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

1011. World Cup Betting (20)——PAT (Advanced Level) Practise

题目信息: 1011. World Cup Betting (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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

PAT World Cup Betting[非常简单]

1011 World Cup Betting (20)(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, footbal

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 be

pat1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 battl

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 bet

Programming Ability Test学习 1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 battl