PAT (Advanced Level) Practice 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.1 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 ( 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.1 1.6
4.1 1.2 1.1
Sample Output:
T T W 39.31
思路:每轮找出最大值的索引,然后再根据索引和公式计算,最后输出。
#include <stdio.h>
double a[][];
int main()
{
char b[]={'W','T','L'};
int c[];
double maxa=;
for(int i=;i<;i++){
maxa=;
for(int j=;j<;j++){
scanf("%lf",&a[i][j]);
if(a[i][j]>maxa){
maxa=a[i][j];
c[i]=j;
}
}
}
double sum=;
for(int i=;i<;i++){
sum*=a[i][c[i]];
}
sum=sum*0.65-;
sum*=;
printf("%c %c %c %.2f\n",b[c[]],b[c[]],b[c[]],sum);
return ;
}
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)的更多相关文章
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...
- 【PAT Advanced Level】1011. World Cup Betting (20)
简单模拟题,遍历一遍即可.考察输入输出. #include <iostream> #include <string> #include <stdio.h> #inc ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...
随机推荐
- Spring整合EasyExcel【基础设计】
前言 Java解析.生成Excel比较有名的框架有Apache poi.jxl.但他们都存在一个严重的问题就是非常的耗内存,poi有一套SAX模式的API可以一定程度的解决一些内存溢出的问题,但POI ...
- 面试官:你说你熟悉jvm?那你讲一下并发的可达性分析
这是why技术的第35篇原创文章 上面这张图是我还是北漂的时候,在鼓楼附近的胡同里面拍的. 那天刚刚下完雨,路过这个地方的时候,一瞬间就被这五颜六色的门板和自行车给吸引了,于是拍下了这张图片.看到这张 ...
- Gridview的stretchMode等属性详解
<GridView android:id="@+id/grid"android:layout_width="fill_parent"android:lay ...
- redis教程-redis环境搭建安装(qq:1324981084)
需要整套redis缓存高可用集群教学视频的加qq:1324981084,本套视频从安装到集群的搭建和源码的解析,从零基础讲解. 1.利用命令将redis下载到/usr/local/文件夹下: wget ...
- MySQL索引底层数据结构
一.何为索引? 1.索引是帮助数据库高效获取数据的排好序的数据结构. 2.索引存储在文件中. 3.索引建多了会影响增删改效率. (下面这张图为计算机组成原理内容,每查询一次索引节点,都会进行一次磁盘I ...
- Ajax工作原理及优缺点
1. Ajax是什么? 全称是 asynchronous javascript and xml,是已有技术的组合,主要用来实现客户端与服务器端的异步通信效果(无需重新加载整个网页的情况下),实现页面的 ...
- (三)LoadRunner术语认识
场景:主要表现为controller中设计与执行测试用例中的用户场景.主要工作有,在controller中选择虚拟用户脚本.设置虚拟用户数量.配置虚拟用户运行时的行为.选择负载发生器.设置执行时间等. ...
- MySql学习-2. NavicatforMySQL 与 MySql的对接以及一些操作:
1.连接: 2.数据库的创建: 3.数据库中表的创建: 4.表的设计: 4.1 设计表: 4.2 增加数据(自动递增只是保证唯一值,即使数据删除了也是得前进):
- Java实体对象为什么要实现Serializable接口?
前言 Java实体对象为什么一定要实现Serializable接口呢?在学JavaSE的时候有些实体对象不实现Serializable不是也没什么影响吗? 最近在学习mybatis的时候发现,老师写的 ...
- 手动配置IP地址
更改适配器属性 -> 选择一个网络,单击右键 -> 属性 -> Internet 协议版本 4 (TCP/IPv4)-> 属性 进入如下界面,开始配置: IP地址: IP地址用 ...