A1011. 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
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int games[];
double odds[], p, maxp, ans;
char name[] = {'W', 'T', 'L'};
for(int i = ; i < ; i++){
maxp = -;
for(int j = ; j < ; j++){
scanf("%lf", &p);
if(p > maxp){
maxp = p;
odds[i] = p;
games[i] = j;
}
}
}
ans = (odds[] * odds[] * odds[] * 0.65 - 1.0) * 2.0 + 0.0005;
printf("%c %c %c %.2lf", name[games[]], name[games[]], name[games[]], ans);
cin >> p;
return ;
}
总结:
1、可以使用数组{'W,'T','L'}来记录结果。
2、四舍五入,可以加一个极小的数。
3、可以边输入边处理。
A1011. World Cup Betting的更多相关文章
- PAT甲级——A1011 World Cup Betting
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT A1011 World Cup Betting(20)
AC代码 #include <cstdio> #include <algorithm> const int max_n = 3; using namespace std; /* ...
- 1011 World Cup Betting (20 分)
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over wer ...
- PAT1011:World Cup Betting
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 ...
- 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 ...
随机推荐
- YAML配置:mapping values are not allowed here
在配置Eureka服务器配置文件的时候,出现了mapping values not allowed here的错误,原因是的冒号 ”:“后面没有空格. 原因分析:yml文件中,键值对是以": ...
- SQL Server2012数据库开启远程连接
在我们使用SQL Server数据库的时候很重要的一点就是开启数据库的远程连接,这是因为很多时候数据库部署在远程的服务器上会比较方便,而部署在客户端的话,由于客户端不固定,所以需要经常去部署,这样容易 ...
- xml-dtd
dtd用于校验XML的语法. dtd步骤: 1.看XML中有多少个元素,有几个元素,在dtd文件中写几个<!ELEMENT> 2.判断元素是简单元素还是复杂元素 -复杂元素:有子元素的元素 ...
- Vue命令行工具vue-cli
前面的话 Vue.js 提供一个官方命令行工具,可用于快速搭建大型单页应用.该工具提供开箱即用的构建工具配置,带来现代化的前端开发流程.只需几分钟即可创建并启动一个带热重载.保存时静态检查以及可用于生 ...
- 基于junit的单元测试类编写
首先定义抽象类BaseTest package com.geostar.gfstack.operationcenter.common.util; import com.google.gson.Gson ...
- windows开关机事件
开关机事件.xml <ViewerConfig> <QueryConfig> <QueryParams> <Simple> <BySource&g ...
- [BZOJ 3498] [PA 2009] Cakes
Description \(n\) 个点 \(m\) 条边,每个点有一个点权 \(a_i\). 对于任意一个三元环 \((i,j,k)(i<j<k)\),它的贡献为 \(\max(a_i, ...
- devops工具
工具类型及对应的不完全列举整理如下: 代码管理(SCM):GitHub.GitLab.BitBucket.SubVersion 构建工具:Ant.Gradle.maven 自动部署:Capistran ...
- ubuntu 14.04zabbix的安装
开始安装 64位 Ubuntu 14.04.5 LTS \n \l 安装zabbix的源,以下操作在root下进行 # wget http://repo.zabbix.com/zabbix/3.0/ ...
- Vue——轻松实现vue底部点击加载更多
前言 需求总是不断改变的,好吧,今天就把vue如何实现逐步加载更多和分布加载更多说下,默认你知道如何去请求数据的哈 一次请求 页面 使用slice来进行限制展现从0,a的数据 <div v-fo ...