1011. World Cup Betting (20)

浙大PAT全套答案_1001至1049. 立即下载

1011. World Cup Betting (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
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.0  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.0*2.5*65%-1)*2 = 37.98 yuans (accurate up to 2 decimal places).

Input

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

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.0 1.6
4.1 1.2 1.1
Sample Output
T T W 37.98

提交代

码

#include <iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    double a[3][3]={0};
    int index[3]={0};
    double sum=1;
    for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    cin>>a[i][j];
    for(int i=0;i<3;i++)
    {
    	int max=0;
    	for(int j=0;j<3;j++)
    	{
    		if(max<a[i][j])
    		{
    			max=a[i][j];
    			index[i]=j;///index[]记录的是第i行纵坐标值 
			}
		}
	}
	for(int i=0;i<3;i++)
	{
		if(index[i]==0)cout<<"W ";
		if(index[i]==1)cout<<"T ";
		if(index[i]==2)cout<<"L ";
	}
	for(int i=0;i<3;i++)
	sum*=a[i][index[i]];
	sum*=0.65;
	sum=(sum-1)*2;
	printf("%.2lf",sum);
    return 0;
}
就用了一个二维数组,so easy!

PAT甲级1011解题代码 PAT甲级A1011解题,参考代码 字符串处理与容器的使用。 立即下载

相关推荐

html python mysql交互_干货!Python与MySQL数据库的交互实战

安装PyMySQL库如果你想要使用python操作MySQL数据库,就必须先要安装pymysql库,这个库的安装很简单,直接使用pip install pymysql;假如这种方式还是安装不上,就用如下链接找一个合适的安装包,进行安装,这个就不细说了。https://www.lfd.uci.edu/~gohlke/pythonlibs/使用Python连接MySQL数据库1)六个常用的连接参数参数...

weixin_31043555的博客 1560

pat---1011

1011. World Cup Betting (20)时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited

yixvjing的专栏 624

双三相电机控制避坑指南:为什么你的SVPWM谐波大?四矢量调制实战解析

本文深入解析双三相电机控制中SVPWM谐波大的问题,并提供四矢量调制实战方案。通过分析谐波来源、四矢量调制原理及工程实现步骤,显著降低电流THD至3-5%,提升系统效率2.3个百分点。特别适合需要优化电机控制的工程师参考。

weixin_30645617的博客 397

浙大ZOJ 1011 NTA问题解决

一、工程代码及算法设计注释 --------------------------------------------------nta.h---------------------------------------------- #ifndef JLU_CCST_NTA_H #define JLU_CCST_NTA_H #include struct SignalPair{ in

xiaogugood的专栏 2479

c语言串口编程详解

串口: 一种异步通信接口,通常用于低速数据传输。RS-232: 最常见的串口标准,定义了电气特性、连接器和信号线。UART: 通用异步收发传输器,是实现串口通信的硬件模块。通过以上内容,你应能够理解并实现C语言在Windows和Linux平台上的串口编程。希望这本手册能帮助你在实际项目中顺利进行串口通信开发。如果有任何疑问或需要进一步的帮助,请随时提问。

jkzyx123的博客 2223

DRV8870电机驱动芯片原理与嵌入式多平台驱动开发

H桥电机驱动芯片是直流电机控制的核心硬件模块,其通过双MOSFET拓扑实现方向与速度的精确调控。工作原理基于电荷泵自举驱动、集成电流检测及多重硬件保护机制,技术价值体现在高集成度、宽压适配(4.5V–45V)与强鲁棒性。典型应用场景涵盖智能机器人执行器、工业自动化设备及电池供电移动终端。本文围绕DRV8870这一主流驱动芯片,深入解析其PH/EN与Dual PWM双控制模式、nFAULT故障响应机制,并结合Arduino/ESP32/STM32三大平台,提供可复用的跨MCU驱动库设计范式与FreeRTOS实

weixin_32251525的博客 656

PAT:A1011 World Cup Betting (20 分)

PAT:A1011 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 ...

Ecloss 610

深入解析组合逻辑环(combinational loop)的成因与解决方案

本文深入解析了数字电路设计中组合逻辑环(combinational loop)的成因与危害。通过边沿检测和中断轮询(round_robin)仲裁器等实例,揭示了代码如何意外形成环路,并对比了插入触发器、重构逻辑以及状态机思维三种核心解决方案,帮助硬件工程师从根本上避免这一常见设计陷阱,确保电路稳定可靠。

weixin_28278377的博客 313

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

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

weixin_30919919的博客 131

【网络与爬虫 53】Scrapy-Prometheus实战指南:打造企业级爬虫监控体系的终极解决方案

本文深入探讨Scrapy-Prometheus集成技术,通过费曼学习法从监控痛点出发,详细讲解如何在Scrapy爬虫中集成Prometheus指标收集系统。涵盖从基础配置到企业级监控体系的完整实战指南,帮助开发者构建可观测性强、可维护性高的分布式爬虫监控平台,实现爬虫性能的精准监控和智能告警。

熵数实验室 1584

ESD防护设计宝典(十一):CE(传导发射)超标问题排查与解决

(Conducted Emission, CE),亦称为传导骚扰,是电子电气设备或系统内部的电压、电流通过信号线、电源线或地线向外传输,对其他电子电气设备或系统造成电磁干扰的物理现象。其。

m0_56451176的博客 856

PAT (Advanced Level) 1011 World Cup Betting (20 分) 【Python/C++】【枚举】

PAT (Advanced Level) 1011 World Cup Betting (20 分) 直接取每一行的最大值就Ok Python: import sys #str_in = input() str_in = input() a = [float(n) for n in str_in.split()] str_in = input() b = [float(n) for n in st...

Irish_Moonshine的博客 376

安卓讲课笔记1.1 安装Android Studio

1. 能安装配置Android Studio; 2. 能创建安卓虚拟机(AVD); 3. 能创建简单安卓应用

howard2005的专栏 3362

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

韩江雪de 小屋 745

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

1011 World Cup Betting (20 分)

1011World 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...

树叶子的博客 473

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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

Genius_panda_ACM的博客 286

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

1011 World Cup Betting (20 分) Java

1011 World Cup Betting (20 分) Java 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 W...

uu22222的博客 392

1011 World Cup Betting (20分)

1011World 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 ...

路途遥远,初心难忘,道阻且长,愿君走出半生,归来仍是少年 284

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

C++养成记 219

1011 World Cup Betting (20 分)

1011World 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...

chen_zan_yu_的博客 323

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 excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting

qq_43789349的博客 229

PAT甲级 1011 World Cup Betting (20分)

1011 World Cup Betting (20分) 题目链接:PAT A 1011 思路分析:嗯…这道题就很迷,我不知道它那个公式是怎么来的,开始还以为是按照题意,不同的数据对应不同的公式,后来才发现所有数据都是那个公式,但是我不太理解(原谅笨笨的我,大家有明白的别忘了告诉我啊~),但是不影响做题。就是找每行中赔率最大的输出它所对应的的字母,然后用那个公式计算收益就可以了。 AC代码: #...

weixin_43684054的博客 425
上一篇: 1009. Product of Polynomials (25)
下一篇: 1013. Battle Over Cities (25) 连通图
fxy流年无悔
博客等级 码龄12年 132粉丝 601原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值