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 ...
随机推荐
- 【转】Cygwin的包管理器:apt-cyg
原文网址:http://zengrong.net/post/1792.htm Cygwin的包管理工具setup.exe实在是难用的让人蛋碎.于是就有了这样一个apt-cyg,可以提供类似于 apt- ...
- MVC Action Filter
ASP.NET MVC Framework支持四种不同类型的Filter: Authorization filters – 实现IAuthorizationFilter接口的属性. Action fi ...
- C# 检测机器是否有声卡设备
有时候我们的程序需要进行音频的播放,则我们首先需要判断机器是否有声卡能够进行音频的播放.在网上找了一下没有发现太多关于如何检机器是否有声卡的例子.我在看了一些文档后自己写了一个小测试程序,如果机器装有 ...
- java创建对象的四种方式
1.最常见的 new 一个 2使用反射机制创建对象,直接调用非构造函数 Class obj=Class.forName("A"); A a=obj.newInstance(); C ...
- CentOS上安装MySQL
1.准备RPM安装包 MySQL-server-5.6.33-1.linux_glibc2.5.x86_64 MySQL-client-5.6.33-1.linux_glibc2.5.x86_64 2 ...
- bzoj 3551 [ONTAK2010]Peaks加强版(kruskal,主席树,dfs序)
Description [题目描述]同3545 Input 第一行三个数N,M,Q. 第二行N个数,第i个数为h_i 接下来M行,每行3个数a b c,表示从a到b有一条困难值为c的双向路径. 接下来 ...
- 【翻译】运行于x86机器上的FreeBSD的PCI中断
来源 http://people.freebsd.org/~jhb/papers/bsdcan/2007/article/article.html 摘要 在拥有多个独立设备的计算机里一个重要的元素是一 ...
- leetcode@ [307] Range Sum Query - Mutable / 线段树模板
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive ...
- HDU-4605 Magic Ball Game 树状数组+离散+dfs
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4605 题意:给一颗树,每个节点有个权值w[u],每个节点只有两个儿子或者没有儿子,从根节点放下一个小球 ...
- SQL2008R2日志传送需要注意点
当SQL2008R2采用日志传送方式进行备份/还原时需要注意事项 主从数据库机器必须是局域网内可互相通过共享访问的主机 主从数据库须添加系统帐号,并将sqlagent服务的启动帐号设定为此帐号,最好主 ...