PAT 1011 World Cup Betting 查找元素
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.0 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.0*2.5*65%-1)*2 = 37.98 yuans (accurate up to 2 decimal places).
Input
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
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.0 1.6
4.1 1.2 1.1
Sample Output
T T W 37.98
题目意思:这其实是一道英文阅读题,中国体育彩票提供的一种“三赢”游戏,对于每一场比赛的三种结果赢、平局、输都有三个赔率,三场比赛作为游戏的一组,选择每一场比赛的一个赔率,那么最后所得到的利润将会是三场比赛赔率乘积的65%,再减去两块钱一次的彩票钱。
解题思路:想要获得最大的利润,找每一场赔率最高的,三场最高的分别是a、b、c,最后的计算公式就是(a*b*c*0.65-1)*2。
三个数一组,在每一组中找到最大的那一个数,保存起来,同时使用ans累乘该最大值,最后套用公式计算即可。
odd
adj. 奇数的;古怪的;剩余的;临时的;零散的
n. 奇数;怪人;奇特的事物
odds
n. 几率;胜算;不平等;差别
#include<cstdio>
#include<cstring>
#include<algorithm>
#define inf 0x7fffffff
using namespace std;
int main()
{
int i,j,t,a[];
double d[],maxs;
char c[]="WTL";
double ans=1.0;
for(i=;i<;i++)
{
maxs=0.0;
for(j=;j<;j++)
{
scanf("%lf",&d[j]);
if(d[j]>maxs)
{
maxs=d[j];
t=j;
}
}
ans*=maxs;
a[i]=t;
}
for(i=;i<;i++)
{
printf("%c ",c[a[i]]);
}
ans=(ans*0.65-)*;
printf("%.2lf\n",ans);
return ;
}
PAT 1011 World Cup Betting 查找元素的更多相关文章
- PAT 1011 World Cup Betting
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over w ...
- pat 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011 World Cup Betting (20分) 比较大小难度级别
题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...
- 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 甲级 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)(代码+思路)
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 ...
- 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 ...
- 1011 World Cup Betting (20 分)
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over wer ...
随机推荐
- html5+css3的神奇搭配
1.关于浮动 浮动的元素会脱离标准文档流(float),从而不占据空间,实现了一行排列多个元素的效果 ,但是又导致上级元素height消失,处理这种情况的方法就是有两种: 1.第一种在css里写个伪类 ...
- Python 分支、循环、条件与枚举
单行注释:# 注释内容多行注释:''' 注释内容 ''' Python 中有三种控制流语句: if for while 注:Python 中没有 Switch 这种开关语句 if 语句检测条件真, ...
- JVM CPU Profiler技术原理及源码深度解析
研发人员在遇到线上报警或需要优化系统性能时,常常需要分析程序运行行为和性能瓶颈.Profiling技术是一种在应用运行时收集程序相关信息的动态分析手段,常用的JVM Profiler可以从多个方面对程 ...
- 《Dotnet9》系列之建站-中文站最好WordPress主题,自媒体,博客,企业,商城主题一网打尽
大家好,我是Dotnet9小编,一个从事dotnet开发8年+的程序员.本文介绍WordPress主题JustNews,本站Dotnet9既是使用WordPress + JustNews主题搭建而成的 ...
- iOS开发makeKeyAndVisible和makeKeyWindow区别
参考链接:https://www.jianshu.com/p/c7647caa8bd1
- IPFS学习-DNS链接
DNSLink 什么是DNS链接 DNS链接使用DNS TXT记录映射域名(如ipfs.io)到一个IPFS地址.因为你可以编辑自己的DNS记录,可以使他们总是指向最新版本的IPFS中的对象(如果修改 ...
- WPF 3D Cube及点击交互
在WPF中构建一个简单的立方体比较容易实现,可参考资料也比较众多.比较麻烦的是处理点击交互. 我在WPF中用两种方式实现了3DCube,效果图如下: 方式一: 最常见的3D内容构建模式,结构如下图. ...
- GO基础之文件操作
一.文件操作的基本API func main() { //绝对路径 fileInfo , err := os.Stat("E:/a.txt") fileInfo , err = o ...
- 剑指offer笔记面试题1----赋值运算符函数
题目:如下为类型CMyString的声明,请为该类型添加赋值运算符函数. class CMyString{ public: CMyString(char* pData = nullptr); CMyS ...
- Linux环境下搭建JDK环境
yum安装 傻瓜式安装,记录几条命令 1.查看可安装的jdk版本(需要安装yum): yum -y list java* 2.安装jdk yum install -y java-1.8.0-openj ...