PAT 1011 World Cup Betting (20分) 比较大小难度级别
题目
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 代表赢,T 代表平,L 代表输),每种结果都有对应的赔率;玩家最终能获得利润的所下注的三个结果的赔率的乘积x65%。
要求,输出能获得最大赔率的结果下,每一场比赛应该押 W 还是 T 还是 L,并输出所获得的最大利润。
看起来很牛逼,“世界杯”都出来了,好像还要会买股票,但其实,呵呵。。我这么给你说吧:
三行输入,每一行有三个数字,选择其中最大的那个,如果它是第一个 输出 W ,如果它是第二个,输出 T, 如果他是第三个,输出 L,并保存这个最大的数。
三行输入结束后,把保存的三个最大的数做乘积,再乘以 65%,再减去1,然后给这个结果 x 2,输出。
你可能从题目中没太看出来这个利润是咋算的,但是你看它最后给你的那个例子就明白了。
the maximum profit would be
(4.1×3.1×2.5×65%−1)×2=39.31yuans (accurate up to 2 decimal places).
代码
就似乎比较大小,很容易理解,可以看一下这个char[]数组的巧妙使用。
#include <iostream>
using namespace std;
int main() {
// 注意字符串结束符包含了 \0,写成c[3]会直接报错
// W 赢 T 平 L 输
char c[4] = {"WTL"};
double profit = 1.0;
// 每一行,是一个比赛三种结果的赔率
for (int i = 0; i < 3; ++i) {
double maxOdds = 0.0;
int index = 0;
for (int j = 0; j < 3; ++j) {
double temp;
cin >> temp;
// 买最大的赔率
if (temp > maxOdds) {
maxOdds = temp;
index = j;
}
}
// 最大的赔率对应的是 W / T / L
printf("%c ", c[index]);
// 利润计算公式题目给出
profit *= maxOdds;
}
// 最终利润
profit = (profit * 0.65 - 1) * 2;
printf("%.2f", profit);
return 0;
}
PAT 1011 World Cup Betting (20分) 比较大小难度级别的更多相关文章
- 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 ...
- PAT Advanced 1011 World Cup Betting (20 分)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 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甲级】1011 World Cup Betting (20 分)
题意: 给出三组小数,每组三个,分别代表一场比赛下注一块钱胜平负的赔率.输出投注的方案并计算投注两块钱期望收获.(赔率相乘后乘上0.65再减去本金2块钱) AAAAAccepted code: #in ...
- 1011 World Cup Betting (20 分)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 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 ...
- 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 ...
- PAT 甲级 1011 World Cup Betting (20)(代码+思路)
1011 World Cup Betting (20)(20 分) With the 2010 FIFA World Cup running, football fans the world over ...
- 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 ...
随机推荐
- PE文件学习(1)DOS和NT
大致结构 DOS头和NT头之间通常还有个DOS Stub DOS头 DOS头的作用是兼容MS-DOS操作系统中的可执行文件 一般没啥用 记录着PE头的位置 DOS头定义部分 typedef struc ...
- phpstorm破解版
查看下载:https://www.7down.com/soft/229568.html 破解:https://www.7down.com/article/305640.html 主题更换和下载:htt ...
- Android | 教你如何使用HwCameraKit接入相机人像模式
目录 介绍 简介 关于本次CodeLab 你将建立什么 你会学到什么 你需要什么 申请Camera相关权限 集成HwCameraKit开放能力 步骤1 模式创建:获取CameraKit实例,创建人像模 ...
- Linux网络服务第五章NFS共享服务
1.笔记 NFS一般用在局域网中,网络文件系统c/s格式 服务端s:设置一个共享目录 客户端c:挂载使用这个共享目录 rpc:111远程过程调用机制 Showmount -e:查看共享目录信息 def ...
- 用libevent写的海康摄像头rtsp客户端
之前一直使用live555作为RTSP的客户端,但其框架臃肿,虽然支持各种格式,但实际中并没有这些需求,关键是其注重于格式的解析,却不注重网络IO,单线程下性能也不高,重新用libevent编写rts ...
- Java初学者最近三次作业的心得体会
作为一个初学者,简单的谈一下自己的作业心得体会.如果你是完全没有接触过Java的学习,本篇博文可能会有些收获,如果你已经学习Java有一段时间了,那么可以放弃这篇文章了,因为这篇文章讲解的是基本的东西 ...
- 第 43 章 Baidu Map
43.1. BMap.Circle var point = new BMap.Point(22.111, 114.111); var styleCircleF = { strokeColor:&quo ...
- NodeJs mysql 开启事务
如题:node后台使用mysql数据库,并使用事务来管理数据库操作. 这里主要讲一个事务的封装并写了一个INSERT 插入操作. code: 基础code: db.config.js const my ...
- 深度使用魅族16T后的评价(本人魅友,绝对客观公正,不要盲目的为手机厂商辩护,想想从当初到现在,魅族正在一步步背离自己的信仰,有问题,解决问题才能有更好的发展)
缺点: 电池电量问题 发布会上,那都是吹的,真是的体验效果掉电很快,大概只有描述的2/3的使用时间 屏幕触控失灵问题 我也看了很多评价,这个也挺多的,可能是魅族品控的问题,某宝到现在没给我退货换货 发 ...
- MySQL 中 on与where筛选条件的区别
在两张表连接的时候才会有on的筛选条件,那么on和where的区别是什么呢? 在inner join中是没有区别的,但是在左连接和右连接中,区别就体现出来了,下面以左连接为例: 1.用on的时候,只对 ...