当前位置:网站首页>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;
}
边栏推荐
- Shell 编程核心技术《三》
- 一文掌握数仓中auto analyze的使用
- Stream流
- 26. Delete the duplicate item C solution in the ordered array
- 测试工程师如何“攻城”(上)
- Pytorch学习(四)
- The 15th youth informatics competition in Shushan District in 2019
- Use canal and rocketmq to listen to MySQL binlog logs
- The CDC of sqlserver can read the data for the first time, but it can't read the data after adding, deleting and modifying. What's the reason
- 在线文本行固定长度填充工具
猜你喜欢
PolyFit软件介绍
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
Bi skills - permission axis
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
TCP两次挥手,你见过吗?那四次握手呢?
92.(cesium篇)cesium楼栋分层
线上数据库迁移的几种方法
"Only one trip", active recommendation and exploration of community installation and maintenance tasks
用实际例子详细探究OpenCV的轮廓绘制函数drawContours()
92. (cesium chapter) cesium building layering
随机推荐
Comment utiliser async awati asynchrone Task Handling au lieu de backgroundworker?
反射(一)
Unity editor extends C to traverse all pictures in folders and subdirectories
Leetcode ransom letter C # answer
Shell programming core technology "four"
C # implementation defines a set of SQL statements that can be executed across databases in the middle of SQL (detailed explanation of the case)
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
HDU 6440 2018中国大学生程序设计网络选拔赛
牛客小白月赛7 F题
Swagger突然发癫
有关架构设计的个人思考(本文后续不断修改更新)
牛客小白月赛7 E Applese的超能力
Wechat reading notes of "work, consumerism and the new poor"
LM10丨余弦波动顺势网格策略
《工作、消费主义和新穷人》的微信读书笔记
指定输出的字符集
Online data migration scheme encountered in the project 1 - general idea sorting and technical sorting
OpenCV的二值化处理函数threshold()详解
2021 Hefei informatics competition primary school group
Pytorch学习(四)