当前位置:网站首页>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; }
边栏推荐
- Database learning - Database Security
- Common redis data types and application scenarios
- Maximum common subsequence
- go语言编程规范梳理总结
- CODING DevSecOps 助力金融企业跑出数字加速度
- Optional parameters in the for loop
- Definition of episodic and batch
- 记录一下树莓派搭建环境中遇到的坑。。。
- PHP high concurrency and large traffic solution (PHP interview theory question)
- OSI 七层模型
猜你喜欢
Crud of MySQL
Common PHP interview questions (1) (written PHP interview questions)
Summary of the second lesson
Live broadcast preview | how to implement Devops with automatic tools (welfare at the end of the article)
First PR notes
Number protection AXB function! (essence)
I include of spring and Autumn
SQL Server learning notes
Codasip为RISC-V处理器系列增加Veridify安全启动功能
Bugku's Ping
随机推荐
Appium自动化测试基础 — APPium基础操作API(一)
Coding devsecops helps financial enterprises run out of digital acceleration
MySQL表字段调整
爱可可AI前沿推介(7.5)
How can the boss choose programmers to help me with development?
Database learning - Database Security
What are the domestic formal futures company platforms in 2022? How about founder metaphase? Is it safe and reliable?
The elimination strategy of redis
B站做短视频,学抖音死,学YouTube生?
Brief introduction of machine learning framework
Can I pass the PMP Exam in 20 days?
P6183 [USACO10MAR] The Rock Game S
Linear DP (basic questions have been updated)
D-snow halo solution
Au - delà du PARM! La maîtrise de l'Université de Pékin propose diverse pour actualiser complètement le classement du raisonnement du NLP
Anti shake and throttling
30岁汇源,要换新主人了
[brief notes] solve the problem of IDE golang code red and error reporting
JMeter performance test: serveragent resource monitoring
Bugku's eyes are not real