【一只蒟蒻的刷题历程】 【PAT】 A1011 世界杯投注

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


题目大意:

随着2010年FIFA世界杯的举办,世界各地的足球迷变得越来越兴奋,因为来自最佳团队的最佳球员正在为南非的世界杯奖杯而战。同样,足球投注迷们通过各种形式的世界杯投注,把钱花在了嘴边。

中国足球彩票提供了“三连胜”游戏。获胜的规则很简单:首先选择其中三场比赛。然后,对于每个选定的游戏,下注三个可能的结果之一-W代表胜利,T代表平局,L代表输局。每个结果都有一个奇数。获胜者的赔率将是三个赔率乘以65%的乘积。

例如,以下是三场比赛的赔率:


1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

为了获得最大的利润,必须在第三游戏中购买W,在第二游戏中购买T,并在第一游戏中购买T。如果每个赌注下注2元,那么最大利润将是(4.1×3.1×2.5×65%−1)×2 = 39.31元(精确到小数点后2位)。

输入规格:

每个输入文件包含一个测试用例。每个案例包含3个游戏的下注信息。每个游戏都占据一行,分别对应于W,T和L的三个赔率。

输出规格

对于每个测试用例,一行打印每个游戏的最佳选择,最大获利精确到2个小数位。字符和数字必须用一个空格分隔。

样本输入:

1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

样本输出

T T W 39.31


代码:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
int main() 
{
   string ans;
   double a,b,c,sum=1;  //每行a,b,c 找到最大值累乘
   for(int i=0;i<3;i++)
   {
   	  cin>>a>>b>>c;
   	  double MAX = max(a , max(b,c)); 
   	  sum*=MAX;
   	  if(MAX==a) ans+="W ";
   	  else if(MAX==b) ans+="T ";
   	  else if(MAX==c) ans+="L ";
   }
   cout<<ans;
   printf("%.2f",(sum*0.65-1)*2);
    return 0;
}

你可能感兴趣的:(PTA)