PAT 1011
1011. 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
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
代码
1 #include <stdio.h>
2
3 int findMaxIndex(double*,int);
4 int main()
5 {
6 double odd[],profit;
7 int index1,index2,index3;
8 const char outPut[] = {'W','T','L'};
9 while(scanf("%lf%lf%lf",&odd[],&odd[],&odd[]) != EOF){
index1 = findMaxIndex(odd,);
profit = odd[index1];
scanf("%lf%lf%lf",&odd[],&odd[],&odd[]);
index2 = findMaxIndex(odd,);
profit *= odd[index2];
scanf("%lf%lf%lf",&odd[],&odd[],&odd[]);
index3 = findMaxIndex(odd,);
profit *= odd[index3];
printf("%c ",outPut[index1]);
printf("%c ",outPut[index2]);
printf("%c ",outPut[index3]);
profit = (profit * 0.65 - ) * ;
printf("%.2lf\n",profit);
}
return ;
}
int findMaxIndex(double *dArray,int n)
{
if(n == )
return -;
int index = ;
double maxValue = dArray[];
int i;
for(i=;i<n;++i){
if(maxValue < dArray[i]){
index = i;
maxValue = dArray[i];
}
}
return index;
}
PAT 1011的更多相关文章
- PAT 1011 World Cup Betting
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over w ...
- PAT 1011 A+B和C (15)(C++&JAVA&Python)
1011 A+B和C (15)(15 分) 给定区间[-2^31^, 2^31^]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个 ...
- pat 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT 1011. A+B和C (15)
给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT 1011 A+B和C
https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952 给定区间[-2^31^, 2^31^]内的3 ...
- PAT——1011. A+B和C
给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...
- PAT 1011 World Cup Betting 查找元素
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- PAT 1011 World Cup Betting (20分) 比较大小难度级别
题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...
随机推荐
- Scrum 体验活动笔记
2014-03-10 Isoftstone library 1.识别角色(用户),形象 :名称.痛处.属性.需求 2.编写故事 story以验证需求是否正确:我们假设(客户) 进行验证结果... ...
- WCF学习笔记(一):WCF简介
转:http://www.cnblogs.com/wengyuli/archive/2009/11/04/1595693.html MSDN上关于WCF给出如下注解: 设计 Windows Commu ...
- HDU 4614-Vases and Flowers(线段树区间更新)
题意: n个花瓶(0-n-1) 现有两个操作, 操作1 给a,f 从a位置开始向后连续插f个花(一个花瓶插一个)若当前花瓶有花则向后找,直到n-1位置如果还有多余的花则丢掉求查完花的第一和最后一个位置 ...
- Channel 详解
java.nio.channels.FileChannel封装了一个文件通道和一个FileChannel对象,这个FileChannel对象提供了读写文件的连接. 1.接口 2.通道操作 a.所有通道 ...
- 【暑假】[深入动态规划]UVa 10618 The Bookcase
UVa 12099 The Bookcase 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=42067 思路: ...
- rpc,客户端与NameNode通信的过程
远程过程:java进程.即一个java进程调用另外一个java进程中对象的方法. 调用方称作客户端(client),被调用方称作服务端(server).rpc的通信在java中表现为客户端去调用服务端 ...
- MariaDB-5.5.32源码编译安装
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:Oracle公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分 ...
- SQL Server Profiler参数说明
上图依次说明为: TextDate 依赖于跟踪中捕获的事件类的文本值: ApplicationName 创建 SQL Server 连接的客户端应用程序的名称.此列由该应用程序传递的值填充,而不是由所 ...
- [二]Json-lib的用法
1.Json字符串 PrintWriter out=response.getWriter(); // String resultJson="{\"name\":\&quo ...
- Jsp中的pageContext对象
这个对象代表页面上下文.组要用于访问页面共享数据.使用pageContext可以直接访问request,session,application范围的属性,看看这些jsp的页面: JSP 页面使用 pa ...