C++ Pat甲级1011 World Cup Betting (20 分)

2023-11-19

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 (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 WT 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

输出:每组数中最大数代表的字母,以及将每组最大数带入公式后求得的 最大利润

转自:柳婼 

这才是女神。。。代码写的太漂亮了。。。。

分析:以三个数一组的形式读取,读取完一组后输出最大值代表的字母,然后同时ans累乘该最大值,最后根据公式输出结果~ 

#include <cstdio>
using namespace std;
int main() {
    char c[4] = {"WTL"};
    double ans = 1.0;
    for(int i = 0; i < 3; i++) {
        double maxvalue = 0.0;
        int maxchar = 0;
        for(int j = 0; j < 3; j++) {
            double temp;
            scanf("%lf", &temp);
            if(maxvalue <= temp) {
                maxvalue = temp;
                maxchar = j;
            }
        }
        ans *= maxvalue;
        printf("%c ", c[maxchar]);
    }
    printf("%.2f", (ans * 0.65 - 1) * 2);
    return 0;
}

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C++ Pat甲级1011 World Cup Betting (20 分) 的相关文章

随机推荐

  • Hadoop知识点整理

    知识点大纲 一 初识Hadoop 1 mapreducer 和rdbms区别 2 结构化数据 非结构化数据 半结构化数据 3 hadoop发展历程 二 关于MapReducer 1 新老API对比 2 MapReducer 执行步骤 3 c
  • filebeat多个日志输出多条索引

    vim filebeat yml filebeat prospectors type log enabled true paths opt zcsy hbase logs hbase hadoop regionserver cd zcsy
  • Windows 10 安装Qt5.15.2以及vs2019

    Windows 10 安装Qt5 15 2以及vs2019 一 安装Qt5 15 2 下载Qt5 15 2 下载地址 阿里云盘 安装 Qt5 15 2 输入账号进行在线安装 点击NEXT进入下一步 注 账号密码需要去QT官网申请帐号 账号申
  • WebSocket + kafka实时推送数据(springboot纯后台)

    逻辑 kafka订阅消费者主题 消费后通过webSocket推送到前端 kafka vue financial webSocket 学习引用 SpringBoot2 0集成WebSocket 实现后台向前端推送信息 World Of Mos
  • Java_web初级学习01搭建环境

    一 安装jdk以及JAVA HOME JRE HOME配置 1 安装jdk 这里可以修改路径 2 设置JAVA HOME和JRE HOME环境变量 计算机 图标上右键 gt 属性 gt 高级系统设置 配置JAVA HOME环境变量 到jdk
  • nginx负载均衡之健康检查

    严格来说 nginx到目前为止没有针对负载均衡后端节点的健康检测的模块 但是可以通过upstream负载均衡组中的max fails number和fail timeout time来间接实现 但还是会把请求转发给故障服务器的 然后再转发给
  • 求最大子序列和及其位置(四种经典方法)

    算法部分 include
  • R

    ggplot plot 画图时 都会有自带的颜色配置 但是比较难看 个人偏向自定义颜色 当然也有很多现成好用的配色方案 如RColorBrewer包 RColorBrewer包 提供了3套很好的配色方案 连续型sequential 生成一系
  • Linux C++: error: redefinition of ‘class xxx’ 的解决方法

    我在Ubuntu上写C 运行程序时遇到error ThinkBook 15p data150 study projects 0408 g g src cpp I include o bin test01 In file included f
  • L - Candy Machine(二分+贪心)

    题意 大体就是查找大于等于这个选定集合的平均值个数的数 选定集合 分析 前提就是这个集合有序 这个可以反着理解当最后一个数加上前缀必然使平均值降低 然后大于平均的增多 不断贪心求最大 代码 include
  • IDEA使用Gradle报错:你的主机中的软件中止了一个已建立的连接

    问题详情 问题解决 关闭电脑的热点分享 再重新加载项目即可
  • 什么是HIS、PACS、LIS、RIS

    HIS 医院bai信息系统 Hospital Information System HIS 利用电子计算机和通讯设备du 为医院所属各部门提zhi供病人诊疗信息dao和行政管理信息的收集 存储 处理 提取和数据交换的能力 并满足所有授权用户
  • dubbo分布式服务

    架构 节点角色说明 Provider 暴露服务的服务提供方 Consumer 调用远程服务的服务消费方 Registry 服务注册与发现的注册中心 Monitor 统计服务的调用次调和调用时间的监控中心 Container 服务运行容器 调
  • Linux磁盘管理命令大全

    1 cd命令 Linux cd命令用于切换当前工作目录至 dirName 目录参数 其中 dirName 表示法可为绝对路径或相对路径 若目录名称省略 则变换至使用者的 home 目录 也就是刚 login 时所在的目录 另外 也表示为 h
  • RedHat7.2系统中安装snmp工具并配置服务

    简单介绍 snmpwalk是SNMP的一个工具 用户可以通过snmpwalk查看支持SNMP协议设备的一些信息 比如IP地址 内存使用率等 snmpwalk是一款比较好用的采集系统信息的工具 安装snmp工具 输入以下指令安装软件包 以普通
  • 常用的 Druid 参数

    Druid 参数 连接池初始化大小 最大连接数 最小空闲连接数这几个连接数有什么作用 他们的关系是怎么样的 初始连接数如果都被占用了 连接池会创建最小空闲数个连接吗 官网 Druid Database for modern analytic
  • 机器学习技术(八)——朴素贝叶斯算法实操

    机器学习技术 八 朴素贝叶斯算法实操 文章目录 机器学习技术 八 朴素贝叶斯算法实操 一 引言 二 导入相关依赖库 三 读取并查看数据 四 数据预处理 五 构建两种模型进行比较 1 只考虑Dayofweek以及District 2 加入犯罪
  • 高校校园网建设方案【含网络拓扑图+拓扑结构图+配置命令】(详细版)

    xxx大学xxx校区网络整体规划设计方案 目 录 一 项目综述 1 1 1学校概况 1 1 1 1 1 1 2建设目标 1 1 2 1 概述 1 1 2 2 具体目标 1 1 3建设原则 1 1 3 1 概述 1 1 3 2 具体原则 2
  • Ubuntu20.04安装g3log、glog和gflags

    建议最好先安装最新版本的cmake 在进行以下安装 cmake安装教程 1 安装gflags 方法一 首先打开终端 git clone https github com gflags gflags git cd gflags mkdir b
  • C++ Pat甲级1011 World Cup Betting (20 分)

    1011 World Cup Betting 20 分 With the 2010 FIFA World Cup running football fans the world over were becoming increasingly