码迷,mamicode.com
首页 > 其他好文 > 详细

1011. World Cup Betting (20)——PAT (Advanced Level) Practise

时间:2014-09-25 19:27:27      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:advanced level   practice   pat   1011   world cup betting   

题目信息:

1011. World Cup Betting (20)

时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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

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

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



代码如下:

#include <iostream>
using namespace std;
int main()
{
	double w[3], t[3], l[3];
	while (cin >> w[0] >> t[0] >> l[0] && !cin.eof())
	{
		cin >> w[1] >> t[1] >> l[1];
		cin >> w[2] >> t[2] >> l[2];
		double sum = 1;
		for (int i = 0; i < 3; i++)
		{
			char ch = 'W';
			if (w[i] < t[i])
				ch = 'T';
			if (l[i] > t[i])
				ch = 'L';
			if (l[i] < w[i])
				ch = 'W';
			switch (ch)
			{
			case 'W':
				sum *= w[i];
				break;
			case 'T':
				sum *= t[i];
				break;
			case 'L':
				sum *= l[i];
				break;
			}
			cout << ch << " ";
		}
		cout.setf(ios_base::fixed, ios_base::floatfield);
		cout.precision(2);
		sum *= 0.65;
		sum -= 1.0;
		sum *= 2.0;
		cout << (float)sum << endl;
	}
}


1011. World Cup Betting (20)——PAT (Advanced Level) Practise

标签:advanced level   practice   pat   1011   world cup betting   

原文地址:http://blog.csdn.net/xianyun2009/article/details/39554775

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!