ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PAT A1011 World Cup Betting

2019-08-23 14:52:12  阅读:279  来源: 互联网

标签:PAT Cup Betting three game each World BettingInfo


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,Cup,Betting,three,game,each,World,BettingInfo
来源: https://www.cnblogs.com/mrdragon/p/11399950.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有