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 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).
译: 随着2010年国际足联世界杯的举办,世界各地的球迷都变得越来越兴奋,因为最好的球队的最好的球员正在南非为世界杯奖杯而战。同样地,足球博彩迷们也把他们的钱放在了他们的嘴边,通过各种各样的世界杯赌注。
中国足球彩票提供了“三连胜”游戏。获胜的规则很简单:首先选择三场比赛中的任何一场。然后对每一个选定的游戏,在三个可能的结果中的一个下注——即 W
代表赢,T
代表平,L
代表输。每个结果都有一个奇数。胜利者的奇数是三个赔率乘以 65%
的乘积。
例如,3 场比赛的赔率如下:
W T L
1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1
为了获得最大的利润,第三局必须买 W
,第二局必须买 T
,第一局必须买 T
。如果每次下注 2
元,则最大利润为(4.1 × 3.1 × 2.5 × 65% − 1 )× 2 = 39.31
元(精确到小数点后 2
位)。
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
.
译:每个输入文件包含一个测试用例,每个用例包含三个游戏的投注赔率信息。每场比赛的三个不同的赔率对应的W
,T
和 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.
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 Idea:
一行数里面找最大数,我很懒,我喜欢 map ,利用 double 类型的赔率做 key ,char 类型的 W ,T , L , 做 value ,每次输入在 map 中插入其对应的 键值对。然后取第一个元素即可。第一个元素的 key 是需要计算的赔率,第一个元素的 value 是需要输出的 W , T , L 中的一个。每次输入之后立即输出,记得 map 需要清空。
The Codes:
#include<bits/stdc++.h>
using namespace std ;
map<double , char , greater<double> > mp ; // 按照关键字 降序 排列的 map
map<double , char , greater<double> >::iterator it ;
int main(){
double w , t , l , sum = 1.0 ;
for(int i = 0 ; i < 3 ; i ++){
mp.clear() ; // 清空 map
cin >> w >> t >> l ;
mp[w] = 'W' ;
mp[t] = 'T' ;
mp[l] = 'L' ;
it = mp.begin() ;
sum *= it -> first ; // 计算最大利润需要选择的赔率
printf("%c " , it -> second) ; // 输出本场比赛利润最大的对应的赌注
}
printf("%.2f " , sum * 1.3 - 2) ; // 计算最大利润并输出
return 0 ;
}
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642的更多相关文章
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 【PAT Advanced Level】1011. World Cup Betting (20)
简单模拟题,遍历一遍即可.考察输入输出. #include <iostream> #include <string> #include <stdio.h> #inc ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...
随机推荐
- CSP & CORS
CSP & CORS 内容安全策略 跨域资源共享 CSP https://developers.google.com/web/fundamentals/security/csp google ...
- Github Trending All In One
Github Trending All In One github trending https://github.com/trending https://github.com/trending/j ...
- asm movbe 指令
movbe MOVBE 目标操作数,源操作数 复制源操作数的数据,交换字节后,移动数据 假如: movbe eax,(float)1000.0 eax == 0x00007A44 movbe eax, ...
- vue技术栈
1 vue 说明:vue生命周期:技术点:1:常用的API:computed,methods,props,mounted,created,components 2vue-cli说明:vue绞手架,用于 ...
- NGK内存爆发式增长,看Baccarat将怎样打造全新的全场景金融生态
从数字货币抵押借贷业务出发,DeFi已经形成了覆盖全场景的全新金融生态. 可以说,除了信贷等少数对现实世界信息存在较多依赖的实体业务,DeFi已经实现了传统金融业务的全面链上迁移.大多数传统金融行业存 ...
- [转]RoboWare Studio的使用和发布器/订阅器的编写与测试
原文地址:https://blog.csdn.net/han_l/article/details/77772352,转载主要方便随时查阅,如有版权要求,请及时联系. 开始ROS学习之前,先按照官网教程 ...
- 关于Python 编码的一点认识
在计算机中,所有数据的存储.运算以及传输都必须是二进制数字,因为计算机只认识0和1. 当一个人把一份数据传给另一个人时,计算机传递的是其实是二进制数字,但这些数字需要被还原为原始信息. 这个工作当然是 ...
- react虚拟dom
- 完整的 LDAP + phpLDAPadmin安装部署流程 (ubuntu18.04)
LDAP 安装部署以及基础使用 因工作需求需要使用ldap管理用户权限,在踩了一系列坑之后,总结了一些流畅的文档,希望可以帮到和曾经的我一样迷茫的人. 基础环境:Ubuntu 18.04 一.安装 r ...
- 后端程序员之路 45、nginx CORS 跨域
在提供api给其它应用使用时,有时我们会要限制它的跨域使用,而有时,我们又要用CORS来打破AJAX只能同源使用的限制 跨域资源共享 CORS 详解 - 阮一峰的网络日志http://www.ruan ...