题目

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

思路

相比上一道radix,这题真简单……

找出每行的最大值,对应的W、T、L即为最佳赌注,套入公式计算出的结果即为最大收益。

代码

#include <iostream>
#include <iomanip>
using namespace std;int main(){char results[] = {'W', 'T', 'L'};float profit = 1.0;for (int i=0; i<3; i++){float best = 0.0;int bet = -1;for (int j=0; j<3; j++){float temp;cin >> temp;if (temp > best){best = temp;bet = j;}}profit *= best;cout << results[bet] << " ";}profit = (profit * 0.65 - 1) * 2;cout << setprecision(2) << fixed << profit << endl;return 0;
}

PAT甲级真题 1011 World Cup Betting (20分) C++实现相关推荐

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

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

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

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

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

  4. 【PAT Advanced Level】1011. World Cup Betting (20)

    简单模拟题,遍历一遍即可.考察输入输出. #include <iostream> #include <string> #include <stdio.h> #inc ...

  5. PAT甲级真题目录(按题型整理)(转自柳神)

    转载自:https://www.liuchuo.net/archives/2502?tdsourcetag=s_pcqq_aiomsg 最短路径 1003. Emergency (25)-PAT甲级真 ...

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

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

  7. PAT甲级真题 1018 A+B in Hogwarts--python解法

    PAT甲级真题 1018 A+B in Hogwarts 提交:2638 通过:1559 通过率:59% If you are a fan of Harry Potter, you would kno ...

  8. 1011. World Cup Betting (20)

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

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

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

最新文章

  1. 【Linux】tail命令
  2. [js高手之路]打造通用的匀速运动框架
  3. Winform中将Bitmap对象通过pictureBox显示图片
  4. ITK:遮盖一张图像给定标签图
  5. 57javabean简介
  6. 数据安全治理的几个基本问题
  7. 计算机考研要过六级吗,本科考研英语过几级 有四六级要求吗
  8. 干货 | 语音识别类产品细分及其应用场景
  9. sharepoint学习资料-个人博客
  10. php怎么判断未定义索引数组,PHP数组查找中的未定义索引
  11. React项目以及降级兼容IE低版本
  12. 基于马科维茨与蒙特卡洛模型的资产最优配置模型(Matlab代码实现)
  13. TAOCP-Reading-计算机程序设计艺术阅读-1-1
  14. 正式“退休”的Flash,未来我们会怀念它吗?
  15. vTestStudio:变体Variant初理解
  16. Anciety 0CTF/TCTF 2018 总结
  17. 2022苹果CMS 全新绿豆二开影视源码app源码完整版带安装教程
  18. Oracle 19c 新特性 —— 自动索引 Automatic indexing
  19. 直击视频会议行业五大痛点提出企业视频会议通话完美解决方案
  20. ecshop和Ucenter 通信失败终极解决方法!(附带php5.3以上,出现其他问题解决方法)

热门文章

  1. python传智播客王铭东_传智播客Python学科的王铭东老师讲的怎么样 |
  2. 手机注册邮箱怎么弄?
  3. 网易校招基础编程题——计算炮击次数
  4. Weka Explorer(探索者界面) 详解(1)
  5. python类型数值操作
  6. 实现仿若依后台管理主要功能
  7. Python 求交错序列前N项和
  8. Redis缓存雪崩缓存击穿缓存穿透
  9. 如何使用S32K1的PDB模块触发多个ADC通道连续采样
  10. 睡眠周期时长测试软件,成为时间管理达人必备的六款软件(干货)