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. 什么是favicon.ico?

    ㈠定义 ⑴所谓favicon,即Favorites Icon的缩写,顾名思义,便是其可以让浏览器的收藏夹中除显示相应的标题外,还以图标的方式区别不同的网站. ⑵根据浏览器的不同,Favicon显示也有 ...

  2. javaScript高级程序设计第3版笔记

    <script src = "xxx.js" defer = "defer"> </script> 在引用外部script时,<s ...

  3. Python基础之变量和常量

    变量 将运算得到中间结果暂存到内存,以便后续程序调用. 变量的命名规则: 变量由字母.数字.下划线搭配组合而成 不能以数字开头,更不能全是数字 不能是Python中的关键字,这些符号和字母已经被Pyt ...

  4. 微信小程序 改变radio(单选钮)默认大小

    /* 单选钮样式 */ radio { transform:scale(0.5); }

  5. C与C++ 中 struct和typedef struct

    总体分两块 1 首先://注意在C和C++里不同在C中定义一个结构体类型要用typedef: typedef struct Student { int a; }Stu; 于是在声明变量的时候就可:St ...

  6. win10专业版安装docker实战

    在win10专业版上安装docker 一,下载Docker for Windows Installer.exe 二,在程序面板---程序----程序和功能中找到启动或关闭windows功能,将hype ...

  7. leetcode题目15.三数之和(中等)

    题目描述: 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中不可以包含重 ...

  8. TCP最大报文段长度MSS

    最大报文段长度(MSS)表示TCP传往另一端的最大数据库的长度.当一个连接建立时,连接的双方都要通告各自需要接收的MSS选项(MSS选项只能出现在SYN报文段中).如果一方不接收来自另一方的MSS值, ...

  9. 微信小程序设置全局变量

    为了提高程序的可用性我们在做项目的时候一定要设置全局变量 微信小程序里面有个app.js,我们可以在这个里面设置全局变量, globalData:{ userInfo:null, test:" ...

  10. SRS之RTMP handshake

    1. SrsRtmpServer::handshake 位于 srs_rtmp_stack.cpp. int SrsRtmpServer::handshake() { int ret = ERROR_ ...