PAT甲级 1011 World Cup Betting (20 分)
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
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
float num[5];
float sum=0.65,max;
int index;
char bet[3]={ 'W','T','L'};
for(int i=0;i<3;i++)
{
cin>>num[0]>>num[1]>>num[2];
max=num[0];
index=0;
for(int i=1;i<3;i++)
{
if(num[i]>max)
{
index=i;
max=num[i];
}
}
sum*=max;//乘以最大的数
cout<<bet[index]<<" ";
}
cout<<fixed<<setprecision(2);
cout<<(sum-1)*2;
return 0;
}
还没有评论,来说两句吧...