PAT甲级(Advanced Level) Practice 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 WT 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% 以后得到的值。

例如,以下是三场比赛的赔率:

 W    T    L
1.1  2.5  1.7
1.2  3.1  1.6
4.1  1.2  1.1

为了获得最大的利润,我们需要在前两场买平局,第三场买胜利。

如果投注 2 元,那么最大利润将是 (4.1×3.1×2.5×65%−1)×2=39.31元(最多保留2 位小数)。

输入格式

输入共三行,每行包含三个浮点数,分别表示一场比赛的胜利(W),平局(T),失败(L)的赔率。

输出格式

输出共一行,先输出可获得最大利润的投注方式,即三场比赛分别投注什么结果(用字母表示),再输出可获得的最大利润(在投注 2 元的情况下),注意结果保留两位小数。

每场比赛每个结果的赔率都是正数,且不会超过 5。同一场比赛的三个结果的赔率不可能相同。

题目解析

简单题,找出3个赔率中最大的即可

代码(c++)

#include <bits/stdc++.h>

using namespace std;

const int N = 5;

int n = 3;
double w, t, l, money = 2;
char ans[N];

int main(){
    for(int i = 1; i <= n; i++) {
        cin >> w >> t >> l;
        if(w > t) {
            if(w > l) ans[i] = 'W', money *= w;
            else ans[i] = 'L', money *= l;
        }
        else {
            if(t > l) ans[i] = 'T', money *= t;
            else ans[i] = 'L', money *= l;
        }
    }
    money = money * 0.65 - 2;                           // 减去投入的钱
    for(int i = 1; i <= n; i++) printf("%c ", ans[i]);
    printf("%.2lf\n", money);
        
    return 0;
}

 

  • 25
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值