PAT1011:World Cup Betting
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.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 思路
很简单,找出每次比赛三种结果的最大赔率的那次结果,每三次比赛输出一下利润,套公式即可。需要特别注意保留n位小数时四舍五入和float转int的坑。
代码
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;
char a[] = "WTL";
const float t = 0.65;
const float point = 0.5; int main()
{
vector<float> bet();
vector<float> maxodd();
vector<char> result;
int N = ;
while(cin >> bet[] >> bet[] >> bet[])
{
int pos = ;
if(max(bet[],bet[]) < bet[])
{
maxodd[N++] = bet[];
pos = ;
}
else if(bet[] > bet[])
{
maxodd[N++] = bet[];
pos = ;
}
else
{
maxodd[N++] = bet[];
pos = ;
}
result.push_back(a[pos]);
if(N == )
{
float profit = * (maxodd[] * maxodd[] * maxodd[] * t - ) + point;
int temp = (int)profit;
float maxprofit = ((float)temp)/;
for(int i = ;i < ;i++)
cout << result[i] << " ";
cout << maxprofit << endl;
N = ;
}
}
}
PAT1011:World Cup Betting的更多相关文章
- pat1011. World Cup Betting (20)
1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...
- 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)(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 World Cup Betting[非常简单]
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 ...
- 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 ...
- PATA 1011 World Cup Betting (20)
1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...
随机推荐
- 单向循环链表C语言实现
我们都知道,单向链表最后指向为NULL,也就是为空,那单向循环链表就是不指向为NULL了,指向头节点,所以下面这个程序运行结果就是,你将会看到遍历链表的时候就是一个死循环,因为它不指向为NULL,也是 ...
- SpriteBuilder切换解决方案以及CCB的修改与保存
在SpriteBuilder中切换解决方案非常简单,可以按cmd+数字键即可. 如上图可以看到数字键1,2,3分别对应于3中不同的解决方案. 注意:当通过在CCB中包含一个Sub File Node的 ...
- 【freeradius】使用radclient调试radius协议
freeradius 自带了非常好的客户端程序 radtest, radclient 用来模拟和调试设备和通信过程.radtest多用于认证,radclient更为强大一些,认证,计费,coa都可以模 ...
- LeetCode之“动态规划”:House Robber && House Robber II
House Robber题目链接 House Robber II题目链接 1. House Robber 题目要求: You are a professional robber planning to ...
- 第一个Polymer应用 - (0)准备工作
原文链接: Getting Started - Your first Polymer application翻译时间: 2014年7月5日翻译人员: 铁锚 关于Polymer 的简介,请参考 CSD ...
- Media Player Classic - HC 源代码分析 2:核心类 (CMainFrame)(1)
===================================================== Media Player Classic - HC 源代码分析系列文章列表: Media P ...
- linux下gtk+一个将字符串大写化的小示例
首先用glade画图形界面: 并且设置gtk元素名称(ID)以及设置事件回调函数. 下面写代码: #include <gtk/gtk.h> #include <string.h> ...
- rubygem若干常用选项参数
可以用gem help commands看所有支持的参数,这个比gem -h显示的全: wisy@wisy-ThinkPad-X61:~/src/ruby_src$ gem help commands ...
- Mac OS 的属性列表文件plist装换
Mac OS系统自身包含有转换plist的工具:plutil.其中-p是以human可读方式显示plist文件,而convert就是转换参数,其中支持的格式有:xml,二进制和json.下面拿一个实际 ...
- 关于非现场审计软件的一些介绍(ACL、IEDA、Teammate)
http://group.vsharing.com/Article.aspx?aid=661512 IDEA是由caseware开发的数据分析软件.caseware的网址如下:http://www.c ...