题目

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 代表赢,T 代表平,L 代表输),每种结果都有对应的赔率;玩家最终能获得利润的所下注的三个结果的赔率的乘积x65%。

要求,输出能获得最大赔率的结果下,每一场比赛应该押 W 还是 T 还是 L,并输出所获得的最大利润。

看起来很牛逼,“世界杯”都出来了,好像还要会买股票,但其实,呵呵。。我这么给你说吧

三行输入,每一行有三个数字,选择其中最大的那个,如果它是第一个 输出 W ,如果它是第二个,输出 T, 如果他是第三个,输出 L,并保存这个最大的数。

三行输入结束后,把保存的三个最大的数做乘积,再乘以 65%,再减去1,然后给这个结果 x 2,输出。

你可能从题目中没太看出来这个利润是咋算的,但是你看它最后给你的那个例子就明白了。

the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 yuans (accurate up to 2 decimal places).

代码

就似乎比较大小,很容易理解,可以看一下这个char[]数组的巧妙使用。

#include <iostream>
using namespace std; int main() {
// 注意字符串结束符包含了 \0,写成c[3]会直接报错
// W 赢 T 平 L 输
char c[4] = {"WTL"};
double profit = 1.0;
// 每一行,是一个比赛三种结果的赔率
for (int i = 0; i < 3; ++i) {
double maxOdds = 0.0;
int index = 0;
for (int j = 0; j < 3; ++j) {
double temp;
cin >> temp;
// 买最大的赔率
if (temp > maxOdds) {
maxOdds = temp;
index = j;
}
}
// 最大的赔率对应的是 W / T / L
printf("%c ", c[index]);
// 利润计算公式题目给出
profit *= maxOdds;
}
// 最终利润
profit = (profit * 0.65 - 1) * 2;
printf("%.2f", profit); return 0;
}

PAT 1011 World Cup Betting (20分) 比较大小难度级别的更多相关文章

  1. 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 ...

  2. PAT Advanced 1011 World Cup Betting (20 分)

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  3. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  4. 【PAT甲级】1011 World Cup Betting (20 分)

    题意: 给出三组小数,每组三个,分别代表一场比赛下注一块钱胜平负的赔率.输出投注的方案并计算投注两块钱期望收获.(赔率相乘后乘上0.65再减去本金2块钱) AAAAAccepted code: #in ...

  5. 1011 World Cup Betting (20 分)

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  6. 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 ...

  7. 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 ...

  8. PAT 甲级 1011 World Cup Betting (20)(代码+思路)

    1011 World Cup Betting (20)(20 分) With the 2010 FIFA World Cup running, football fans the world over ...

  9. 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 ...

随机推荐

  1. GitHub 热点速览 Vol.17:在?各家视频会员要不要?

    作者:HelloGitHub-小鱼干 摘要:经济实用,用作上周的 GitHub 热点的横批再合适不过.先不说 GitHub Trending 上不止一个的会员共享项目,免你找好友刷脸要会员,这项目实在 ...

  2. shift count is too large

    STM8S是8 bit单片机在STM8S中 unsigned long是32位, unsigned short和unsigned int都是16位,unsigned char是8位. 以以下代码编译时 ...

  3. 2019-2020-1 20199310《Linux内核原理与分析》第二周作业

    1.问题描述 众所周知,计算机是20世纪最伟大的发明之一,计算机是如何工作的呢?本文主要通过计算机的组成结构和工作原理,以及汇编代码工作过程来进行详细叙述. 2.解决过程 2.1 冯·诺依曼体系结构 ...

  4. udp包最大数据长度是多少

    因为udp包头有2个byte用于记录包体长度. 2个byte可表示最大值为: 2^16-1=64K-1=65535    udp包头占8字节, ip包头占20字节, 65535-28 = 65507 ...

  5. Linux系统硬件时间12小时制和24小时制表示设置

    目前的服务器status是下面这样的 服务器系统    centos7 Linux系统时间      Fri Mar 20 15:26:27 CST 2020 Linux系统硬件时间  Fri 20 ...

  6. 【Django】runserver 0.0.0.0:0 后,究竟发生了什么

    WSGI协议 Django是遵循WSGI协议设计的 WSGI协议主要包括server和application两个部分: WSGI server:负责从客户端接收请求,将request转发给applic ...

  7. Java 后台设置session成功,获取为空

    cookie secure当服务器使用https时,容易出现漏洞SSL cookie without secure flag set,敏感cookie这时就需要打开cookie secure,服务器端 ...

  8. SSH公钥登录和RSA非对称加密

    SSH登录方式 接触过Linux服务器的同学肯定用过SSH协议登录系统,通常SSH协议都有两种登录方式:密码口令登录和公钥登陆. 一.密码口令(类似于账号密码登录) 1.客户端连接服务器,服务器把公钥 ...

  9. yum报[Errno 256] No more mirrors to try

    解决方法: yum clean all            #清除yum缓存yum makecache      #将服务器软件包写到本地缓存,提高包的搜索.安装效率

  10. mybatis if test标签的使用

    2019独角兽企业重金招聘Python工程师标准>>> 在使用mybatis 有时候需要进行判断的. 而我们知道mybatis获取值有两种方式 #{}和${}的. 那么,在mybat ...