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 ...
随机推荐
- I.MX6 Android Linux shell MMPF0100 i2c 获取数据
#!/system/bin/busybox ash # # I.MX6 Android Linux shell MMPF0100 i2c 获取数据 # 说明: # 本文主要记录通过shell脚本来获取 ...
- Ruby准备工作
解释性语言,自上而下执行,纯面向对象,跨平台,动态绑定,没有多重继承.NetBeans sun公司开发irb指令可快速实时输入并返回结果 quit 或者exitrdoc hello.rb 生成html ...
- 也用 Log4Net 之将日志记录到数据库的后台实现 (二)
也用 Log4Net 之将日志记录到数据库的后台实现 (二) 大家下午好,昨天讲了配置,今天我们讲讲后台实现,在完成了后台实现后,我们才能真正意义上的解决把自定义属性字段值录入到数据库中. 在开写之 ...
- POJ 2001-Shortest Prefixes(Trie 入门)
题意:给你一组串,求每个串在组中唯一标志的最短前缀 分析:保存树上经过各节点的单词个数,扫描每个串当经过节点单词个数是一(能唯一标志)结束 #include <map> #include ...
- 黑盒测试用例设计方法&理论结合实际 -> 错误推断法
一 概念 基于经验和直觉推测程序中所有可能存在的各种错误, 从而有针对性的设计测试用例的方法. 二 错误推断法的应用 基本思想:列举出程序中所有可能有的错误和容易发生错误的特殊情况,根据他们选择测试 ...
- iOS7程序后台运行
介绍 这次 iOS7 对程序后台运行进行了加强,但是仅仅是加强而已,要想像 Android 程序那样自由当然就别想了,苹果这么做主要还是出于电池使用时间考虑,但是这次的加强对大部分程序基本够用. 在介 ...
- POJ 3254 poj3254 Corn Fields
题意:给出一个n行m列的草地,1表示肥沃,0表示贫瘠,现在要把一些牛放在肥沃的草地上,但是要求所有牛不能相邻,问你有多少种放法. 思路: DP[i][j]=sum(dp[i-1][k]); i表示当前 ...
- HDU4862-Jump(最大流量最大费用流)
题意:有n*m的格子,每一个格子包含一个数字,0-9.你初始的能量为0,你可以玩k次,每一个你可以选择你现在的格子的正下方或者正右方的任意一个格子跳,但必须是之前没有跳过的格子.每玩一次你都可以跳任意 ...
- Objective-C Runtime 运行时之五:协议与分类
Objective-C中的分类允许我们通过给一个类添加方法来扩充它(但是通过category不能添加新的实例变量),并且我们不需要访问类中的代码就可以做到. Objective-C中的协议是普遍存在的 ...
- iOS中几种定时器 - 控制了时间,就控制了一切
在软件开发过程中,我们常常需要在某个时间后执行某个方法,或者是按照某个周期一直执行某个方法.在这个时候,我们就需要用到定时器. 然而,在iOS中有很多方法完成以上的任务,到底有多少种方法呢?经过查阅资 ...