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 ...
随机推荐
- 【机器学习】算法原理详细推导与实现(六):k-means算法
[机器学习]算法原理详细推导与实现(六):k-means算法 之前几个章节都是介绍有监督学习,这个章解介绍无监督学习,这是一个被称为k-means的聚类算法,也叫做k均值聚类算法. 聚类算法 在讲监督 ...
- stm32f407使用Keil uV5建立工程日志
目录结构 Common ——包括延时函数等公用函数 STM32F4_FWLIB ——固件库 Project ——UV5工程相关文件 Main ...
- Lua类的继承 参考实现
参考url: https://blog.codingnow.com/cloud/LuaOO 最近在思考lua类的继承实现 ,参考了云风的类实现,感觉他的更像是接口写法.于是尝试用自己的方式重写了类实例 ...
- Element-UI ( Dropdow )下拉菜单组件command传输对象
通过 :command绑定对象数据,handleCommand方法处理数据 template <div v-for="(item, index) in FlyWarningList&q ...
- mac系统目录结构
1 符合unix传统的目录 /bin 传统unix命令的存放目录,如ls,rm,mv等. /sbin 传统unix管理类命令存放目录,如fdisk,ifconfig等等. /usr 第三方程序安装目录 ...
- pip 安装源-Python学习
1.国内常用的安装源 -- 豆瓣:https://pypi.douban.com/simple -- 阿里:https://mirrors.aliyun.com/pypi/simple --中国科技大 ...
- linux中权限管理命令(chmod/chown/chgrp/unmask)
目录 chmod chown chgrp umask chmod 解释 命令名称:chmod 命令英文原意:change the permissions mode of a file 命令所在路径:/ ...
- Django request对象与ORM简介
form表单 form表单默认是以get请求提交数据的 http://127.0.0.1:8000/login/?username=admin&password=123 action参数 1. ...
- 在pycharm中如何设置代码对齐竖线
方法:启动pycharm软件,打开一个文件,点 file 菜单,选择 settings,在弹出的setting菜单中依次选择editor-->general-->appearance,然后 ...
- MySql 部分字段去重
select * from personal_question_answer where answer_id in ( select min(answer_id) from personal_ques ...