PTA(Advanced Level)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.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,S,L的值,每次都找最大的(设为\(x_n\)),最后要求的就是:\((x_1*x_2*...x_n*0.65-1)*2\)
代码
#include<bits/stdc++.h>
using namespace std;
int get_max(int x, int y, int z)
{
if(x >= y && x >= z)
return 1;
if(y >= x && y >= z)
return 2;
if(z >= x && z >= y)
return 3;
}
int main()
{
double w,t,l;
double ans = 1.0;
int cond;
while(cin>>w>>t>>l)
{
cond = get_max(w,t,l);
switch(cond)
{
case 1: cout << "W "; ans *= w; break;
case 2: cout << "T "; ans *= t; break;
case 3: cout << "L "; ans *= l; break;
}
}
ans *= 0.65;
ans -= 1;
ans *= 2;
printf("%.2f\n", ans);
return 0;
}
引用
https://pintia.cn/problem-sets/994805342720868352/problems/994805504927186944
PTA(Advanced Level)1011.World Cup Betting的更多相关文章
- PAT (Advanced Level) 1011. World Cup Betting (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- 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
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 ...
- 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 ...
随机推荐
- delphi将一个list中包含的元素,从另一个中删除,如果在另一个中存在的话
Function StrList_Del(StrList,DelStrList:String):String; //将DelStrList中包含的元素,从Strlist中删除,如果在Strlist中存 ...
- [心得]暑假DAY 5
好久没更新博客了 最近事情太多太多 tarjan进阶,点双边双 T2压力 最大坑点:点双缩点 它不是直接把割点连成树(割点会有环) 而是用割点作”中介“,联接点双构成一颗树(所谓圆方树) 接着在上面进 ...
- 20191114-4 Beta发布用户使用报告
20191114-4 Beta发布用户使用报告 此作业要求参见:https://edu.cnblogs.com/campus/nenu/2019fall/homework/10007 组名:胜利点 组 ...
- 2、记录代码----Ajax
$.ajax({ url:'/content-engine/index.php/tracker/confirmSendEmail', async: false, //默认为true,同意异步传输 da ...
- android data binding jetpack VI 清理一些概念。BR 运算表达式
android data binding jetpack VIII BindingConversion android data binding jetpack VII @BindingAdapter ...
- docker-compose快速部署环境笔记
# 在含有 docker-compose.yml 的文件夹下 构建容器# 如有使用 Dockerfile 在修改 Dockerfile 文件之后再次执行如下即可应用修改docker-compose u ...
- TensorFlow 学习(1)——第一个程序:线性回归
目前这个程序还有很多地方没有搞懂,先跑一跑例程看看效果如何.从结果来看,最终的训练成果能够接近于预设的数据
- python调用系统命令的方法
1.os模块 (1)system()方法 这个方法是直接调用标准C的system() 函数,在一个子终端运行系统命令 (2)poen()方法 这个方法执行命令后通过一个管道文件将结果返回 3.subp ...
- [go]os.Open方法源码
file, err := os.Open("./buf.go") func Open(name string) (*File, error) { return OpenFile(n ...
- 查询出与jack互为好友的人名字
建表 /* Navicat MySQL Data Transfer Source Server : connect1 Source Server Version : 50611 Source Host ...