码迷,mamicode.com
首页 > 其他好文 > 详细

1011. World Cup Betting (20)(最大值)

时间:2015-01-30 07:54:12      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

 

 

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.0  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.0*2.5*65%-1)*2 = 37.98 yuans (accurate up to 2 decimal places).

 

Input

 

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

 

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.0 1.6

4.1 1.2 1.1

Sample Output

T T W 37.98

 

 

这题的IO例子纯坑爹! 例子里面输出百分位是四舍五入的,我一开始没注意,后来很高兴的注意到了,把它四舍五入了,然后就怎么都WA了。

最后试着把  +0.005 去掉,竟然AC了技术分享  

 

AC代码:

 

技术分享
  1 #include <iostream>
  2 
  3 #include <iomanip>
  4 
  5 #include <string>
  6 
  7 using namespace std;
  8 
  9  
 10 
 11  
 12 
 13 double a[3][3];
 14 
 15  
 16 
 17  
 18 
 19 int main()
 20 
 21 {
 22 
 23     while(cin>>a[0][0])
 24 
 25       {
 26 
 27             cin>>a[0][1]>>a[0][2];
 28 
 29             int i,j;
 30 
 31           for(i=1;i<=2;i++)
 32 
 33                   for(j=0;j<=2;j++)
 34 
 35                         cin>>a[i][j];
 36 
 37             double max[3]={0,0,0};
 38 
 39             string   cc[3];
 40 
 41             for(i=0;i<=2;i++)
 42 
 43             {
 44 
 45                   int temp;
 46 
 47                   for(j=0;j<=2;j++)
 48 
 49                   {
 50 
 51                   if(a[i][j]>max[i])
 52 
 53                         {
 54 
 55                               max[i]=a[i][j];
 56 
 57                               temp=j;
 58 
 59                         }
 60 
 61                   }
 62 
 63             if(temp==0) 
 64 
 65                   {
 66 
 67                         cc[i]="W";
 68 
 69                   }
 70 
 71                   if(temp==1) cc[i]="T";
 72 
 73                   if(temp==2) cc[i]="L";
 74 
 75             }
 76 
 77  
 78 
 79             for(i=0;i<=2;i++)
 80 
 81                   cout<<cc[i]<<" ";
 82 
 83  
 84 
 85             double sum=1.0;
 86 
 87        
 88 
 89             for(i=0;i<=2;i++)
 90 
 91                   sum=sum*max[i];
 92 
 93                   sum=sum*0.65;
 94 
 95         sum=(sum-1)*2;
 96 
 97  
 98 
 99             cout<<fixed<<setprecision(2)<<sum<<endl;
100 
101  
102 
103       }
104 
105  
106 
107       return 0;
108 
109 }
110 
111  
112 
113  
View Code

 

1011. World Cup Betting (20)(最大值)

标签:

原文地址:http://www.cnblogs.com/xiaoyesoso/p/4261442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!