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. java常见问题 ——编辑报错1

    报错1 The method add(CatNode) in the type List<CatNode> is not applicable for the arguments (Str ...

  2. MessagePack Java Jackson Dataformat 在 Map 中不使用 String 为 Key 的序列化

    当你希望在 Map 中不使用 String 为 Key,那么你需要使用 MessagePackKeySerializer 来为 key 进行序列化. 本测试方法,可以在 https://github. ...

  3. TensorFlow源代码学习--1 Session API reference

    学习TensorFlow源代码,先把API文档扒出来研究一下整体结构: 一下是文档内容的整理,简单翻译一下 原文地址:http://www.tcvpr.com/archives/181 TensorF ...

  4. 「HEOI2014」大工程

    问题分析 首先不难想到是虚树.建完虚树需要保持节点间原先的距离关系. 然后总距离和最小距离用树形DP求,最大距离用两遍dfs即可.注意统计的时候只对关键点进行统计. 真是麻烦 参考程序 ac的时候是l ...

  5. Ranger使用solrCloud存储审计日志

    Ranger使用solrCloud存储审计日志 标签(空格分隔): Ranger 1, Zookeeper 搭建 1,忽略.默认已经搭建好zk 集群. VECS17820:2181,VECS17821 ...

  6. redis 提供 6种数据淘汰策略

    淘汰策略的原因 在 redis 中,允许用户设置最大使用内存大小 server.maxmemory,在内存限定的情况下是很有用的.譬如,在一台 8G 机子上部署了 4 个 redis 服务点,每一个服 ...

  7. 如何用Sha256进行简单的加密或者解密

    个人是今天第一次使用Sha256对数据进行加密操作,以往都是直接使用MD5加密最多也就是加盐之后再进行加密 不过可能是个人应用的只是简单的一个对数据的加密,所以感觉目前和MD5差距并不是很大. 1.首 ...

  8. TCP输出 之 tcp_write_xmit

    概述 tcp_write_xmit函数完成对待发送数据的分段发送,过程中会遍历发送队列,进行窗口检查,需要TSO分段则分段,然后调用tcp_transmit_skb发送数据段: 源码分析 static ...

  9. Java-GC 垃圾收集算法

    程序计数器.虚拟机栈.本地方法栈随线程而生,随线程而灭. 栈帧随着方法的开始而入栈,随着方法的结束而出栈. 这几个区域的内存分配和回收都具有确定性,在这几个区域内不需要过多考虑回收的问题,因为方法结束 ...

  10. js 执行总结1

    一. function sayHi() { let x; let y; try { throw new Error(); } catch (x) { // 局部 x = 1; console.log( ...