英文描述
World Cup Betting (20)
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.0 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.0 * 2.5 * 65%-1) * 2 = 37.98 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.0 1.6
4.1 1.2 1.1
Sample Output:
T T W 37.98
中文描述
世界杯赌博
伴随着2010世界杯的开赛,在南非,来自于最好的球队的球员在为世界杯奋战时来自世界各地的球迷也变得越来越兴奋。同样的,赌球运动也开始了。
中国足球博彩会提供一个“三倍赢”游戏。胜利的规则很简单:首先选择任何三场比赛。然后对于每个选择的游戏,在三个选项中赌一个可能的结果,其中W代表赢,T代表平局,L代表失败。对于每个结果是赌注赔率的分配。胜利者的3个赌注赔率将相乘最后在乘上65%。
为了获得最大利润,从第三场游戏中买W,第二场游戏中买T,第一场游戏中买T,如果每注2元,那么最大利润就是(4.1 * 3.0 * 2.5 * 65%-1) * 2 = 37.98元(精确到两位小数)。
输入规格:
每个输入文件包含一个测试用例。每个用例包含3场游戏的赌博信息。每场游戏有三个赌注赔率相当于W、T和L。
输出规格:
对于每个测试用例,在一行内输出每场游戏赌注最大的值和最大的利润,小数点精确到两位。字符和数字之间用空格间隔。
样例输入:
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
样例输出:
T T W 37.98
分析与解题
第一次做的时候有点紧张,主要是题没读懂,就算现在,题意也没有很清楚,可能是关于博彩行业的事情,自己对这些东西又不是特别懂。当你把题读明白后,会发现这根本不是算法题了,基本的输出输出题。可是从另一个方面也反应出我的英语是有些差了,今天看了一会英语四级,只看了3个听力的新闻播报我就快被折磨的不行了。心里很down,可还是要加油!不气馁,不骄傲。
我是通过9个数字的来分布标记W、T和L的,后来看到他们写的弄了一个数组来标记,这方法比较简单下次可取。
最后说一点关于浮点数的事情,浮点数有时候是很不精确的,不论精确到第几位。比如你算0.1 mul 0.2,结果是0.0200000004。先写一点注意事项:用double就用lf,用float就用f,我说的是格式控制符,也就是说double a,输出或者输出a的时候都要scanf(“%lf”, &a)或是printf(“%lf”, a)。
C语言实现
1 |
|