PAT--1011 World Cup Betting

版权声明:未经过本人同意不得转发 https://blog.csdn.net/weixin_42956785/article/details/84782159

1011 World Cup Betting

超级无敌大水题,难度可能就在看懂题目吧。。哈哈哈哈哈
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%的乘积。

例如,3场比赛的赔率如下:

W T L
1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1
要获得最大利润,必须购买W第3场比赛,T第2场比赛和T第1场比赛。如果每次下注需要2元,则最大利润为(4 。1 × 3 。1 × 2 。5 × 6 5 %- 1 )× 2 = 3 9 。3 1元(精确到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<cstdio>
#include<iostream>
using namespace std;
int main()
{
	double data;
	char wtl[5];
	double sum = 1;
	for (int i = 0; i < 3; i++)
	{
		double max = 0;
		int index = 0;
		for (int j = 0; j < 3; j++)
		{
			cin >> data;
			if (data > max)
			{
				max = data;
				index = j;
			}
		}
		sum *= max;
		if (index == 0)
		{
			wtl[i] = 'W';
		}
		else if (index == 1)
		{
			wtl[i] = 'T';
		}
		else wtl[i] = 'L';
	}
	for (int i = 0; i < 3; i++)
	{
		printf("%c ", wtl[i]);
	}
	sum = sum * 0.65 - 1;
	sum = sum * 2;
	printf("%.2f", sum);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42956785/article/details/84782159