当前位置:网站首页>1011 World Cup betting (20 points) (pat a)
1011 World Cup betting (20 points) (pat a)
2022-07-04 19:37:00 【Acacia moon tower】
Problem Description:
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
The question : Find the maximum value in each row separately , And then evaluate .
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
double fmax(double a, double b, double c) {
double t = max(a, b);
return max(t, c);
}
int main() {
double w, t, l, ans = 1;
int k = 0;
char e[5];
for(int i = 0; i < 3; i++) {
scanf("%lf %lf %lf", &w, &t, &l);
if(fmax(w,t,l) == w) {
e[k++] = 'W';
ans *= w;
} else if(fmax(w,t,l) == t){
e[k++] = 'T';
ans *= t;
} else {
e[k++] = 'L';
ans *= l;
}
}
ans = (ans*0.65-1)*2;
for(int i = 0; i < k; i++) {
printf("%c ", e[i]);
}
printf("%.2lf\n", ans);
return 0;
}
边栏推荐
- 页面元素垂直水平居中、实现已知或者未知宽度的垂直水平居中。
- "Only one trip", active recommendation and exploration of community installation and maintenance tasks
- socket编程demo二
- YOLOv5s-ShuffleNetV2
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- 指定输出的字符集
- BCG 使用之CBCGPProgressDlgCtrl進度條使用
- Shell 编程核心技术《三》
- Double colon function operator and namespace explanation
- 双冒号作用运算符以及命名空间详解
猜你喜欢

English grammar_ Noun - use

联想首次详解绿色智城数字孪生平台 破解城市双碳升级难点

升级智能开关,“零火版”、“单火”接线方式差异有多大?

To sort out messy header files, I use include what you use

92. (cesium chapter) cesium building layering

The 300th weekly match of leetcode (20220703)

Lenovo explains in detail the green smart city digital twin platform for the first time to solve the difficulties of urban dual carbon upgrading

BCG 使用之新建向导效果

Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?

黑马程序员-软件测试--09阶段2-linux和数据库-31-43修改文件权限字母发的说明,-查找链接修改文件,查找文件命令,链接文件,压缩解压方式,vi编辑器基本使用,
随机推荐
Shell programming core technology "four"
Have you guys ever used CDC direct Mysql to Clickhouse
Personal thoughts on Architecture Design (this article will be revised and updated continuously later)
Crawler (6) - Web page data parsing (2) | the use of beautifulsoup4 in Crawlers
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
Introduction to polyfit software
有关架构设计的个人思考(本文后续不断修改更新)
指定输出的字符集
socket编程demo二
Educational codeforces round 22 E. Army Creation
1003 emergency (25 points) (PAT class a)
HDU 6440 2018中国大学生程序设计网络选拔赛
Master the use of auto analyze in data warehouse
“只跑一趟”,小区装维任务主动推荐探索
The 15th youth informatics competition in Shushan District in 2019
Shell programming core technology "I"
PointNeXt:通过改进的模型训练和缩放策略审视PointNet++
In flinksql, in addition to data statistics, is the saved data itself a state
Detailed explanation of issues related to SSL certificate renewal
测试工程师如何“攻城”(下)