当前位置:网站首页>Noi / 1.5 37: mercenaries
Noi / 1.5 37: mercenaries
2022-07-05 15:35:00 【Graylan_】
describe
The maximum strength of mercenaries is M, The initial physical strength value is 0、 The combat effectiveness is N、 Have X An energy element .
When a mercenary's stamina is just M when , Before you can participate in a M Days of combat , At the end of the battle period, the physical strength will be 0. In the same combat period , Mercenaries fight every continuous battle n God , Combat effectiveness will rise 1 spot ,n For the combat effectiveness at the beginning of the current combat period .
After a combat period , Mercenaries need to use several energy elements to maximize their physical strength M, To participate in the next combat period . The physical strength restored by each energy element does not exceed the current combat effectiveness . Each energy element can only be used once .
Excuse me, : What is the maximum combat effectiveness of mercenaries .
Input
A line consists of three integers M、N、X, Two adjacent integers are separated by a single space .M、N、X No more than 10000 The positive integer .
Output
Output an integer , For the maximum combat effectiveness of mercenaries .
The sample input
5 2 10
Sample output
6
Problem analysis :
The combat effectiveness of soldiers is continuously increased through circulation , Set an intermediate value t Indicates that after the cycle ends , The greatest combat power of soldiers , When x<t,
namely x-t<0, The capability element is 0, Out of the loop , Finally, keep using n Record the change of value , In order to obtain the maximum combat power
Source code :
#include <iostream>
using namespace std;
int main()
{
int m,n,x,t;
cin>>m>>n>>x;
while(x>0)
{
t=m/n;
if(m%n!=0)
t++;
if(x<t)
break;
x-=t;
t=m/n;
n+=t;
}
cout<<n;
return 0;
}边栏推荐
- 亿咖通科技通过ISO27001与ISO21434安全管理体系认证
- MySQL5.7的JSON基本操作
- 【简记】解决IDE golang 代码飘红报错
- JS topic - console log()
- Summary of the third class
- Crud de MySQL
- JMeter performance test: serveragent resource monitoring
- "Sequelae" of the withdrawal of community group purchase from the city
- I include of spring and Autumn
- 华为哈勃化身硬科技IPO收割机
猜你喜欢

SQL Server learning notes

Common MySQL interview questions

P1451 求细胞数量/1329:【例8.2】细胞

Bubble sort, insert sort

MySQL之CRUD

Ecotone technology has passed ISO27001 and iso21434 safety management system certification

Summary of the third class

Write a go program with vscode in one article

30岁汇源,要换新主人了

Good article inventory
随机推荐
I spring and autumn blasting-1
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
episodic和batch的定义
Summary of the third class
CODING DevSecOps 助力金融企业跑出数字加速度
How can the boss choose programmers to help me with development?
P6183 [USACO10MAR] The Rock Game S
go学习 ------jwt的相关知识
【 note 】 résoudre l'erreur de code IDE golang
JMeter performance test: serveragent resource monitoring
Reasons and solutions for redis cache penetration and cache avalanche
爱可可AI前沿推介(7.5)
Bugku easy_ nbt
Detailed explanation of C language branch statements
Detailed explanation of QT creator breakpoint debugger
力扣今日题-729. 我的日程安排表 I
swiper. JS to achieve barrage effect
String modification problem solving Report
美团优选管理层变动:老将刘薇调岗,前阿里高管加盟