当前位置: 首页 > news >正文

PAT A1011 World Cup Betting

1011 World Cup Betting

分数 20

作者 CHEN, Yue

单位 浙江大学

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

 

 * 输入九个浮点数,每三个浮点数位一组,从每组中选择最大的数,并且输出下标对应的编号
 * (W,T,L),输入可以用map来存储,编号亦可以用map来处理,具体看代码实现。

/*** 输入九个浮点数,每三个浮点数位一组,从每组中选择最大的数,并且输出下标对应的编号* (W,T,L),输入可以用map来存储,编号亦可以用map来处理,具体看代码实现。
*/#include <iostream>
#include <map>
#include <vector>using namespace std;const int INF = 1e9;int main()
{map<int, double> mp;for(int i=0; i<9; ++i){double db;cin >> db;mp[i] = db;}vector<int> vec;for(int i=0; i<9; i+=3){int maxid = i; //最大下标double maxv = -INF; //最大值for(int j=i, k=0; k<3; ++j, ++k){if(mp[j] > maxv){maxv = mp[j];maxid = j;}}vec.push_back(maxid);}map<int, string> op = {{0, "W"}, {1, "T"}, {2, "L"}};double res = 1;for(int i=0; i<3; ++i){int id = vec[i];cout << op[id % 3] << ' ';res *= mp[id];}res *= 0.65;res = (res - 1) * 2;printf("%.2f\n", res);return 0;
}

http://www.lryc.cn/news/63486.html

相关文章:

  • Android 拍照以及相册中选择(适配高版本)————上传头像并裁剪(一)
  • 带你了解现在的LED显示屏技术
  • AI模型推理(1)——入门篇
  • MySQL--表的基本查询--0410--15
  • Scala语言入门以及基本语法
  • Linux shell编程 循环语句for continue break
  • leetcode 643. 子数组最大平均数 I
  • TDA4VM/VH 芯片硬件 mailbox
  • 如何利用Trimble RealWorks三维激光扫描仪进行外业测量和内业处理?
  • mysql数据备份
  • 排队接水--贪心
  • 数字温度传感器-DS18B20
  • 【算法】【算法杂谈】从M个数中等概率的选出n个数,保证每一个数的选中概率都是n/m(蓄水池算法)
  • vue3+ts+vite自适应项目——路由、layout布局
  • 数据库之约束、索引和事务
  • centos --libreoffice使用
  • Steam-V Rising 私人服务器架设教程
  • SpringBoot+Vue3实现登录验证码功能
  • spring2:创建和使用
  • 前端如何处理后端一次性传来的10w条数据?
  • Codeforces Round 867 (Div. 3)(A-G2)
  • 蓝奥声核心技术分享——一种无线低功耗配置技术
  • kafka集群模拟单节点故障
  • 笔记:vue-cli-service
  • Amazon S3 对象存储Java API操作记录(Minio与S3 SDK两种实现)
  • ChatGPT技术原理 第六章:对话生成技术
  • 【C++ 八】写文件、读文件
  • 【学习笔记】CF613E Puzzle Lover
  • 软考报名资格审核要多久?证明材料要哪些?
  • 2023-04-27 polardbx-LSM-tree的Parallel Recovery性能优化