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
思路
  • 简单来说题意就是:给定W,S,L的值,每次都找最大的(设为\(x_n\)),最后要求的就是:\((x_1*x_2*...x_n*0.65-1)*2\)
代码
#include<bits/stdc++.h>
using namespace std;
int get_max(int x, int y, int z)
{
if(x >= y && x >= z)
return 1;
if(y >= x && y >= z)
return 2;
if(z >= x && z >= y)
return 3;
}
int main()
{
double w,t,l;
double ans = 1.0; int cond;
while(cin>>w>>t>>l)
{
cond = get_max(w,t,l);
switch(cond)
{
case 1: cout << "W "; ans *= w; break;
case 2: cout << "T "; ans *= t; break;
case 3: cout << "L "; ans *= l; break;
}
}
ans *= 0.65;
ans -= 1;
ans *= 2;
printf("%.2f\n", ans);
return 0;
}
引用

https://pintia.cn/problem-sets/994805342720868352/problems/994805504927186944

PTA(Advanced Level)1011.World Cup Betting的更多相关文章

  1. PAT (Advanced Level) 1011. World Cup Betting (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  2. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  3. PAT 1011 World Cup Betting

    1011 World Cup Betting (20 分)   With the 2010 FIFA World Cup running, football fans the world over w ...

  4. PAT 甲级 1011 World Cup Betting (20)(20 分)

    1011 World Cup Betting (20)(20 分)提问 With the 2010 FIFA World Cup running, football fans the world ov ...

  5. PAT 甲级 1011 World Cup Betting (20)(代码+思路)

    1011 World Cup Betting (20)(20 分) With the 2010 FIFA World Cup running, football fans the world over ...

  6. 1011 World Cup Betting (20 分)

    1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over wer ...

  7. PAT甲 1011. World Cup Betting (20) 2016-09-09 23:06 18人阅读 评论(0) 收藏

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

  8. PAT 甲级 1011 World Cup Betting (20)(20 分)(水题,不用特别在乎精度)

    1011 World Cup Betting (20)(20 分) With the 2010 FIFA World Cup running, football fans the world over ...

  9. PATA 1011 World Cup Betting (20)

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

随机推荐

  1. jquery blur()函数 语法

    jquery blur()函数 语法 作用:当元素失去焦点时发生 blur 事件.blur() 函数触发 blur 事件,或者如果设置了 function 参数,该函数也可规定当发生 blur 事件时 ...

  2. java常用检验接口control方式

    @Controller public class ItemController { @Autowired private ItemService itemService; @RequestMappin ...

  3. Git入门学习和使用

    #开篇废话 开篇废话又回来了,离开博客算是有一年了,之间曾经痛下很多次决心,继续写博客,后来都失败了,前年为了申请个CSDN专家,每天发博客,那个高产的状态,现在已然不行了,时过境迁,当时为了吃口饱饭 ...

  4. 如何使用getattr运行单个函数

    import sys def foo(): print("哈哈想不到吧") if __name__ == '__main__': getattr(sys.modules[__nam ...

  5. 【转】python 输入一个时间,获取这个时间的下一秒

    原文:https://blog.csdn.net/l_d_56/article/details/84832198 输入一个时间,获取这个时间的下一秒 PS:下面代码使用于 python 2.7 tim ...

  6. git *** Please tell me who you are.错误

    GIT 中提示 please tell me who you are   如果使用git过程中出现了,please tell me who you are ,需要设置一下使用者的身份. 1.git c ...

  7. JxBrowser开启调试模式,JxBrowser debug

    原文: 一.问题描述 像一般的浏览器都带了调试功能,按F12就能打开,在JxBrowser中如何开启调试模式了. 二.解决方法 以下代码就能开启调试模式: import com.teamdev.jxb ...

  8. [转]spring的filter中targetFilterLifecycle作用

    在web.xml中进行配置,对所有的URL请求进行过滤,就像"击鼓传花"一样,链式处理. 配置分为两种A和B. A:普通配置 在web.xml中增加如下内容:<filter& ...

  9. LC 662. Maximum Width of Binary Tree

    Given a binary tree, write a function to get the maximum width of the given tree. The width of a tre ...

  10. Zabbix - 配置服务器对第三方服务的监控

    需求: 需要配置zabbix监控,使得zabbix服务器可以监控到另一台服务器上运行的第三方服务的状态,当状态异常时发送告警邮件. 限制:被监控的服务器不允许安装任意客户端,且该台服务器不能联通外网 ...