当前位置:网站首页>1011 World Cup Betting (20 分)(PAT甲级)
1011 World Cup Betting (20 分)(PAT甲级)
2022-07-04 17:58:00 【相思明月楼】
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
题意:分别找出每一行中的最大值,然后求值。
#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;
}
边栏推荐
- Using FTP
- 长城证券开户安全吗 买股票怎么开户
- How to use async Awati asynchronous task processing instead of backgroundworker?
- 2014合肥市第三十一届青少年信息学奥林匹克竞赛(小学组)试题
- .NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
- In flinksql, in addition to data statistics, is the saved data itself a state
- Caché WebSocket
- prometheus安装
- php伪原创api对接方法
- To sort out messy header files, I use include what you use
猜你喜欢

在线SQL转Excel(xls/xlsx)工具

读写关闭的channel是啥后果?

物联网应用技术的就业前景和现状

Rookie post station management system based on C language

BI技巧丨权限轴

Safer, smarter and more refined, Chang'an Lumin Wanmei Hongguang Mini EV?

Opencv functions and methods related to binary threshold processing are summarized for comparison and use

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

如何使用Async-Awati异步任務處理代替BackgroundWorker?

2022CoCa: Contrastive Captioners are Image-Text Fountion Models
随机推荐
Have you guys ever used CDC direct Mysql to Clickhouse
Caché WebSocket
876. 链表的中间结点
千万不要只学 Oracle、MySQL!
Oracle with as ORA-00903: invalid table name 多表报错
LeetCode 赎金信 C#解答
The difference and usage between substr (), slice (), and substring () in the string interception methods of "understand series after reading"
Shell programming core technology II
Build your own website (15)
Oracle with as ora-00903: invalid table name multi report error
自由小兵儿
反射(一)
SSL证书续费相关问题详解
神经网络物联网平台搭建(物联网平台搭建实战教程)
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
Shell 編程核心技術《四》
1672. 最富有客户的资产总量
测试工程师如何“攻城”(上)
IBM WebSphere MQ检索邮件
Process of manually encrypt the mass-producing firmware and programming ESP devices