PAT 甲级 1011 World Cup Betting

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 (4.1×3.1×2.5×65%−1)×2=39.31 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
结尾无空行

题意描述:

找出每行中赔率最大的,输出它所对应的的字母,然后用题目所给的公式计算收益就可以了。

解题思路:

每一行的赔率是独立的,因此可以单独对每一行计算最值,把相应的字母以及赔率都存储起来,最后再根据公式计算即可。

难度评测:Easy

AC代码实现:

#include <bits/stdc++.h>
using namespace std;
typedef pair<double, char> P;int main() {char ch[] = {'W', 'T', 'L'};double a[3];vector<P>v;for(int i = 0; i < 3; i++) {double mx = 0;int ind;for(int j = 0; j < 3; j++) {cin >> a[j];if(a[j] > mx) {mx = a[j];ind = j;}}v.push_back(P(mx, ch[ind]));}double ans = 1;for(auto tmp : v) {printf("%c ", tmp.second);ans *= tmp.first;}ans = (ans * 0.65 - 1) * 2;printf("%.2f", ans);
}

PAT 甲级 1011 World Cup Betting相关推荐

  1. PAT甲级1011 World Cup Betting:[C++题解]模拟

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:每场取最大的数. ac代码 #include<bits/stdc++.h> using namespace std;int ...

  2. 【PAT甲级】 1011 World Cup Betting

    [PAT甲级] 1011 World Cup Betting 原题 With the 2010 FIFA World Cup running, football fans the world over ...

  3. 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 ...

  4. 浙江大学PAT上机题解析之1011. World Cup Betting (20)

    1011. World Cup Betting (20) 时间限制  400 ms 内存限制  32000 kB 代码长度限制  16000 B 判题程序    Standard 作者    CHEN ...

  5. 1011. World Cup Betting (20)

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

  6. 1011 World Cup Betting (20 分)_14行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 With the 2010 FIFA World Cup running, football fans the world ove ...

  7. PAT甲级真题 1011 World Cup Betting (20分) C++实现

    题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...

  8. 【PAT甲级 ArrayList存放class】1011 World Cup Betting (20 分) Java版 3/3通过 四舍五入保留两位小数

    题目 一共给9个数,3*3,找到每行最大,按照题目要求套算式,计算就行 坑 & 心得 没啥坑,一次通过,用到的知识点是:自定义排序.四舍五入保留两位小数 DecimalFormat df = ...

  9. PAT甲题题解-1011. World Cup Betting (20)-误导人的水题。。。

    题目不严谨啊啊啊啊 式子算出来结果是37.975 样例输出的是37.98 我以为是四舍五入的啊啊啊,所以最后输出的是sum+0.005 结果告诉我全部错误啊 结果直接保留两位小数就可以了啊啊啊啊 水题 ...

最新文章

  1. Jmeter(一)http接口添加header和cookie --转载
  2. python【蓝桥杯vip练习题库】BASIC-9特殊回文数
  3. [YTU]_1066 ( 输入n个数和输出调整后的n个数)
  4. 种群计数 (pop_count)
  5. mac java maven 设置
  6. 期货黄金与现货黄金比较
  7. 前端学习(586):在元素中动态添加类与伪类
  8. @Autowired注解能用在static属性吗?autowired注入static属性上为null
  9. mariadb mysql 创建_MariaDB 创建数据库,学习MariaDB,MariaDB教程,MariaDB手册,MariaDB学习,MariaDB实例 | 开发学院...
  10. c语言程序设计自学跟谁好,双辽c语言编程学习,双辽学c语言编程哪个好,双辽学c语言编程自学好还是报班好...
  11. 多么漂亮的重载构造方法呀!爱上.net
  12. RSocket 基于消息传递的反应式应用层网络协议
  13. 注册(二)之增加绑定
  14. 计算机生成目录步骤word,word生成目录步骤,word怎样做目录
  15. 相关性评估:皮尔逊相关系数,R2
  16. 微积分:2.1导数中的中值定理
  17. 1116: 删除元素(数组)
  18. Win10 IE浏览器无法打开HTTPS网站的解决方法--win10专业版
  19. cad角度怎么画_软件CAD | 直线amp;构造线
  20. CPU卡PSAM卡 响应指令

热门文章

  1. 华铭智能属于芯片概念吗_绩优滞涨的科技股名单来袭!两大活跃资金加仓股仅6只射频芯片龙头在列...
  2. 计算机发展史的pdf文档,计算机的发展历程.pdf
  3. HTML——Http协议
  4. echarts看板效果图:流光折线图、3d柱状图、3d饼图、3d地图
  5. 【IoT】NFC CPU 卡 AID 应用标识符规范
  6. 电子版标书怎么做?有哪些特点?
  7. Python django 在线练习考试系统
  8. outlook 日历 桌面_将Microsoft Outlook固定到桌面背景
  9. BI数据仪表盘可能带来的三大陷阱
  10. 山东大学项目实训十三——FFmpeg