# 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:

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

### 题目解读

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;
}```

0 条评论

• ### PAT 1044 Shopping in Mars (25分) 二分法

Shopping in Mars is quite a different experience. The Mars people pay by chained...

• ### PAT 1007 Maximum Subsequence Sum (25分) 最大连续子序列和

Given a sequence of K integers { N​1​​ , N​2​​ , ..., N​K​​ }. A continuous subs...

At the beginning of every day, the first person who signs in the computer room w...

• ### matplotlib quiver箭图绘制案例

quiver绘制表示梯度变化非常有用，下面是学习过程中给出的两个例子，可以很好理解quiver的用法

• ### 【PAT甲级】World Cup Betting

版权声明：本文为博主原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接和本声明。 ...

• ### 语义分割--Global Deconvolutional Networks for Semantic Segmentation

语义分割 Global Deconvolutional Networks for Semantic Segmentation BMVC 2016 ...

• ### 基于注意力的基于神经网络的远程监督情感态度提取(CS CL)

在情感态度提取任务中，目标是识别文本中实体之间的情感关系。本文提供了一种在情感态度提取任务中基于注意力的上下文编码器的研究。基于此任务，采用两种类型的注意力上下...

• ### 【SAP FICO系列】SAP ABAP的替代和校验

I. Creating, activating and transporting validations and substitutions 1. Whic...

• ### 使用深度强化学习测试三消游戏（CS AI）

测试视频游戏是制作过程中的关键步骤，需要花费大量时间和资源。一些软件公司正试图使用​​人工智能来替代能够使用人工代理的系统来减少对人力资源的需求。我们研究了使用...

• ### Codeforces Round #618 (Div. 2)-Non-zero

这个题是说通过最小的修改次数，是数列和不能为0，乘积不能为0； 那么也即数列中不存在0，如果存在0的一定要改，存在0的只能变成1，那我们考虑变成1之后，的和是...