题目来源自PAT网站 https://www.patest.cn/
题目描述:
1011. World Cup Betting (20)
With the 2010 FIFAWorld Cup running, football fans the world over were becoming increasinglyexcited as the best players from the best teams doing battles for the World Cuptrophy in South Africa. Similarly, football betting fans were putting theirmoney where their mouths were, by laying all manner of World Cup bets.
Chinese FootballLottery provided a "Triple Winning" game. The rule of winning wassimple: first select any three of the games. Then for each selected game, beton one of the three possible results -- namely W for win, T for tie, and L forlose. There was an odd assigned to each result. The winner's odd would be theproduct of the three odds times 65%.
For example, 3games' 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 themaximum profit, one must buy W for the 3rd game, T for the 2nd game, and T forthe 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 filecontains 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 upto 2 decimal places. The characters and the number must be separated by onespace.
SampleInput
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
SampleOutput
T T W 37.98
题目翻译:
1011.世界杯赌博
在2010FIFA世界杯进行时,当最好的球队中最棒的球员在为了世界杯奖杯而在南美拼搏时,来自世界各地的球迷非常激动和兴奋。同样的,爱好足球赌博的人也通过实际行动参与了进来,不过用的是各种世界杯赌博方式。
中国足球彩票推出了一个“三倍赢”游戏。胜利的规则非常简单:首先选择任意三个游戏。然后对于每个选择的游戏,赌其中三个可能的结果中的其中一个,叫W是赢,T的是平局,L是输。对于每个结果都有一个剩余的值。胜利者的剩余将会是三个剩余值的65%。
例如,3个游戏的剩余在下面给出:
W T L
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
要想获得最大的利润,必须在第三个游戏中买W,第二个游戏中买T,第三个游戏中买T。如果每次赌博花费2元,则最大的最大的利润将会是(4.1*3.0*2.5*65%-1)*2= 37.98元。(精确到两位小数)
输入
每个输入文件包含一个测试实例。每个实例包含三个游戏的赌博信息。每个游戏有一行,里面包含三个与W、T和L对应的剩余值。
输出
对于每个测试实例,在一行中输出每个游戏最好的赌博选择,还有精确到两位小数的最大利润。字符和数字必须用一个空格分隔。
样例输入:
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
样例输出:
T T W 37.98
答案代码:
#include
double bet[3][3];
int main()
{
int i1,i2;
for(i1=0;i1<3;++i1)
for(i2=0;i2<3;++i2)
scanf("%lf",&bet[i1][i2]);
char C[3]={'W','T','L'};
int maxi[3]={0,0,0};
double sum=0.65*2;
for(i1=0;i1<3;++i1)
for(i2=0;i2<3;++i2)
{
if(bet[i1][i2]>bet[i1][maxi[i1]])
maxi[i1]=i2;
}
for(i1=0;i1<3;++i1)
{
printf("%c ",C[maxi[i1]]);
sum=sum*bet[i1][maxi[i1]];
}
sum-=2;
printf("%.2lf\n",sum);
return 0;
}
说明与心得:
翻译不太好翻译,比如best bet ofeach game我找不出啥词来形容,下注?押宝?可能是我语文不太好。上面那两大段只有65%是有用的…不过题目真简单。