PAT 1011 World Cup Betting (20分) 比较大小难度级别


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:

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


人们为了庆祝“世界杯”,开办了一个叫“三连胜”游戏,规则如下:首先从所有比赛中随机选择个,然后对于每一个游戏做一个下注(W 代表赢,T 代表平,L 代表输),每种结果都有对应的赔率;玩家最终能获得利润的所下注的三个结果的赔率的乘积x65%。

要求,输出能获得最大赔率的结果下,每一场比赛应该押 W 还是 T 还是 L,并输出所获得的最大利润。


三行输入,每一行有三个数字,选择其中最大的那个,如果它是第一个 输出 W ,如果它是第二个,输出 T, 如果他是第三个,输出 L,并保存这个最大的数。

三行输入结束后,把保存的三个最大的数做乘积,再乘以 65%,再减去1,然后给这个结果 x 2,输出。


the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 yuans (accurate up to 2 decimal places).



#include <iostream>
using namespace std;

int main() {
	// 注意字符串结束符包含了 \0,写成c[3]会直接报错
	// W 赢 T 平 L 输
	char c[4] = {"WTL"};
	double profit = 1.0;
	// 每一行,是一个比赛三种结果的赔率
	for (int i = 0; i < 3; ++i) {
		double maxOdds = 0.0;
		int index = 0;
		for (int j = 0; j < 3; ++j) {
			double temp;
			cin >> temp;
			// 买最大的赔率
			if (temp > maxOdds) {
				maxOdds = temp;
				index = j;
		// 最大的赔率对应的是 W / T / L
		printf("%c ", c[index]);
		// 利润计算公式题目给出
		profit *= maxOdds;
	// 最终利润
	profit = (profit * 0.65 - 1) * 2;
	printf("%.2f", profit);

	return 0;

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可