codeforces 651A Joysticks

基于pytest+Allure+Python+CANoe的汽车诊断自动化测试框架搭建实战 自动化测试是提升软件质量和研发效率的关键技术,其核心原理是通过脚本模拟人工操作,实现测试用例的自动执行与结果验证。在汽车电子领域,诊断服务测试是确保车辆ECU(电子控制单元)功能正常的重要环节,传统手动测试在面对海量用例和频繁回归时效率低下。本文聚焦于如何利用Python的pytest测试框架、Allure报告工具以及Excel数据驱动,构建一个与Vector CANoe仿真测试环境深度集成的自动化测试解决方案。该方案通过Python调用CANoe的COM接口,实现了诊断报文的自动发送与响应验证,并结合Al 阅读详情

A. Joysticks
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.

Input

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

Output

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

Examples
input
3 5
output
6
input
4 4
output
5
Note

In the first sample game lasts for 6 minute by using the following algorithm:

  • at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%;
  • continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%;
  • at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%;
  • continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%;
  • at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%;
  • at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%.

After that the first joystick is completely discharged and the game is stopped.


题意是两个手柄吧是,然后只能一个充电,充电效率是1%/min,放电效率是2%/min,然后一分钟开始的的时候决定这一分钟是充电还是放电,充电可以充的超过100%,放电的话到0%就结束,或者在一分钟开始的时候应该放电的那个是1%也结束,因为1 - 2 = -1,只能撑半分钟

每分钟有一次机会可以换充放电的手柄,问两个人最长能坚持多长时间

用循环就可以搞定了,就是注意下0%和1%这两种情况就可以了

注意边界1 1输出0,1 2输出1


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	//保证a < b
	if (a > b) {
		int tem = a;
		a = b;
		b = tem;
	}
	int cou = 0;
	//每次都是电量多的放电到不能再放为止才切换充电器
	//如果较大电量<= 1了,就说明这一分钟完不成了
	while (b > 1) {
		if (b - 2 <= 0) {
			cou++;
			break;
		};
		while (b - 2 > 0) {
			b -= 2;
			a += 1;
			cou++;
		}
		//保证a < b
		if (a > b) {
			int tem = a;
			a = b;
			b = tem;
		}
	}
	printf("%d\n", cou);
	return 0;
}





ROS相机内参标定详细步骤指南 相机标定的目的是为了确定相机内部参数和外部参数,以便修正图像并将图像坐标映射到世界坐标,或者从世界坐标映射到图像坐标。这个过程是计算机视觉和三维感知任务的关键步骤之一,它有以下主要目的: 1. **减小畸变**:相机镜头和传感器可能引入径向和切向畸变,使得图像中的直线变得弯曲或者物体的形状不准确。通过标定相机,可以矫正这些畸变,使图像更准确。 阅读详情

相关推荐

移远EC21/EC200模组休眠功耗从13mA降到6mA,我排查了这3个坑(附完整AT指令流程)

本文详细介绍了移远EC21/EC200模组休眠功耗从13mA优化至6mA的完整解决方案,涵盖硬件设计检查、AT指令配置、RTOS调度优化和固件兼容性验证等关键步骤。通过系统性的低功耗问题诊断框架,帮助IoT设备开发者有效提升电池续航能力,特别适合智能水表等电池供电场景应用。

weixin_30715523的博客 534

Codeforces 651A Joysticks 【贪心】

题目链接:Codeforces 651A Joysticks

世界很大 841

【通俗易懂】Windows系统安装TensorRT

NVIDIA TensorRT是一个由NVIDIA公司开发的用于深度学习推理的高性能SDK。它专门设计用于在NVIDIA GPU上进行高效的神经网络推理,能够大幅度提升深度学习模型的推理速度和效率。TensorRT的主要特点包括:模型优化:TensorRT通过层融合、精度校准、动态形状等技术优化模型,减少推理时的计算量和内存占用。多精度推理:支持多种精度推理,包括FP32、FP16、INT8等,以平衡性能和精度。

王尼莫的博客 1586

Codeforces 651A Joysticks

Codeforces 651A Joysticks题目大意如下: 有两个游戏棒,开始各含有charge[0]和charge[1]的电量,都大于0。现在要使用这两个游戏棒玩游戏,但是如果其中只要有一个游戏棒没有电(也就是0)那么游戏就没有办法进行下去。现在知道只有一个充电口,而且充电只能在每分钟的开始阶段,每分钟可以充入1%的电量,然而玩游戏每分钟会消耗2%的电量(只能一个在充电,一个在玩)。现在

kornberg_fresnel的博客 449

CGNS快速入门到实战(二):VS配置调用CGNS静态链接库

CGNS快速入门到实战这一系列分成三篇文章展开叙述,具体有:(一)CGNS静态链接库编译;(二)VS配置调用CGNS静态链接库;(三)CGNS文件及案例展示。本篇文章重点讲述VS配置调用CGNS静态链接库。

ahang_99的博客 2616

二、时间序列的预处理

一般情况下,拿到一个观察值序列之后,首先要对它的平稳性和纯随机性进行检验,这两个重要的检验称为序列的预处理。根据检验的结果可以将序列分为不同的类型,对不同类型的序列我们会采用不同的分析方法。 一、平稳性检验 1、特征统计量 (1)概率分布           数理统计的基础知识告诉我们分布函数或者密度函数能够完整地描述一个随机变量的统计特征。同样,一个堆积变量族{Xt} 的统计特征也完全由...

Nicole的博客 2万+

CodeForces - 651A Joysticks

A - Joysticks Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You c...

Wolfgang 286

Harness Engineering:让Coding Agent真正落地生产

本文将带你系统性地了解如何让Coding Agent真正落地生产,核心是依托(全球领先的持续交付、云成本管理、 feature flagging、安全治理一体化平台),结合企业级AIDD(AI-Driven Development)的工程化实践,构建一套可信赖、可观测、可扩展、可治理的Coding Agent落地体系。核心概念与理论基础:什么是Coding Agent?它和普通的AI代码补全工具(比如GitHub Copilot)有什么区别?什么是Harness Engineering?

移动开发前沿的博客 454

【CodeForces】[651A]Joysticks

大意是两个操纵杆一个充电器 每一个分钟只能充一个,充的那个电量+1不充的那个电量-2 需要注意的是 当有一个电量为1时则必须要充 否则就游戏结束 当然 当有电量为0的游戏也结束所以可以模拟来做 并且考虑一下特殊情况就好了

BoilTask Talk Show 486

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

zemax像差参数Ray Fan/Spot Diagram/MTF/....讲解三

weixin_72050316的博客 1384

手把手教你学Simulink--基于Simulink的风力发电系统用双馈电机控制仿真建模

特点高效节能:在广泛的风速范围内保持高效的能量转换。独立控制有功和无功功率:通过控制转子电流实现对有功和无功功率的独立调节。较低的成本:相比直接驱动或全功率变流器方案,成本较低。挑战控制复杂度较高:需要复杂的控制算法来实现有功和无功功率的解耦控制。对电网波动敏感:需要良好的稳定性控制策略以应对电网电压波动。利用Simscape Electrical中的模块构建DFIG的物理模型,配置参数如电阻、电感、极对数等。matlab深色版本% 添加DFIG电机模块。

MHD0815的博客 346

Joysticks CodeForces - 651A

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1percent and second one is charged at a2 percent. You can connect char...

weixin_42171215的博客 234

EMC意义下的共模(Common Mode)和差模(Differential Mode)

在电子产品中,信号或电源通过两根导线传输。对比维度差模(DM)共模(CM)电流方向一进一出,相等相反同向、相等回流路径两根导线组成的闭合回路地或外壳EMC影响较小容易辐射干扰,重点治理类型定义有用信号干扰信号抑制方法常规滤波器、电感、电容共模电感、磁环、屏蔽、接地技术等。

weixin_43199439的博客 1241

Codeforces 651A Joysticks(模拟)

题目:http://codeforces.com/problemset/problem/651/A 代码: #include #include using namespace std; int main() { int a,b; while(~scanf("%d%d",&a,&b)) { int ans=0; if(a==1&&b==

Pig_Me的博客 412

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

CodeForces 651 A Joysticks

CodeForces 651 A Joysticks

Dacc123的博客 666

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

codeforces 651A A. Joysticks

Description Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1percent and second one is charged at a2 percent. You

WOLF的博客 448

Statistics and Machine Learning Toolbox

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

Codeforces 651A Joysticks【贪心】

题意: 两根操纵杆,每分钟操纵杆消耗电量2%,每分钟又可以给一个操纵杆充电1%(电量可以超过100%),当任何一个操纵杆电量降到0时,游戏停止。问最长游戏时间。 分析: 贪心,每次选择电量剩余最少的充电。 代码: #include<iostream> #include<algorithm> using namespace std; c...

An55511的博客 165

codeforces 651A Joysticks【贪心】

A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have tw

wyjwyl的专栏 1078

【CodeForces 651A】Joysticks 模拟

题意:给定a,b,每个单位时间可以将a,b中一台加1,一台减2,求最久可以支持多久。#include <cstdio> #include <algorithm> using namespace std;const int N=256;int n1,n2; int cnt;int main(void) { scanf("%d%d",&n1,&n2); while (n1>0&&n2>0

Sdchr 350

Codeforces 651A Joysticks

A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have tw

Chunzhen的博客 421

CodeForces 651A:Joysticks【模拟】

A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have tw

所谓梦想,就是永不停息的疯狂。。。。。 760

Codeforces 651 A. Joysticks

A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have ...

weixin_30376453的博客 114

CodeForces - 651A A. Joysticks

A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Friends are going to play console. They have tw

Singular__point的博客 462

【贪心】【codeforces】651A Joysticks

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=336194 就是最开始有两个油箱,初始有a1(percent) a1(percent)的油,只有一根加油管,如果加油可以一分钟加1%的油,不加油的那个油箱一分钟会掉2%的油 当有油箱出现没有油的情况时游戏结束,要求找到使游戏时间最长的策略(油箱的油可以超过100%) ...

weixin_30567225的博客 99

CodeForces 651A-Joysticks

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute.

小I的博客 423
上一篇: hdu1394 Minimum Inversion Number 最小逆序数 线段树单点更新区间查询
下一篇: codeforces 651B Beautiful Paintings
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值