We Are Discuss About CODECHEF SOLUTION
Single-use Attack CodeChef Solution
Single-use Attack CodeChef Solution
Problem
Chef is playing a video game, and is now fighting the final boss.
The boss has � health points. Each attack of Chef reduces the health of the boss by �.
Chef also has a special attack that can be usedĀ at most once, and will decrease the health of the boss byĀ ļæ½.
Chef wins when the health of the boss isĀ ā¤0.
What is theĀ minimumĀ number of attacks needed by Chef to win?
Input Format
- The first line of input will contain a single integerĀ ļæ½, denoting the number of test cases.
- The first and only line of each test case will contain three space-separated integersĀ ļæ½,ļæ½,� ā the parameters described in the statement.
Output Format
For each test case, output on a new line the minimum number of attacks needed by Chef to win.
Constraints
- 1ā¤ļæ½ā¤1000
- 1ā¤ļæ½<ļæ½ā¤ļæ½ā¤100
Sample 1:
Input
Output
4 100 25 40 100 29 45 46 1 2 78 15 78
4 3 45 1
Explanation:
Test caseĀ 1:Ā Chef can attack the bossĀ 4Ā times normally. This results inĀ 25+25+25+25=100Ā damage, which is enough to defeat the boss.
Test caseĀ 2:Ā Chef can attack the bossĀ 2Ā times normally, then use the special attack. This results inĀ 29+29+45=103Ā damage, which is enough to defeat the boss.
Test caseĀ 3:Ā Chef can proceed as follows:
- First, use the special attack. This leaves the boss withĀ 46ā2=44Ā health.
- Then, useĀ 44Ā normal attacks to defeat the boss, since each one doesĀ 1Ā damage.
This takes a total ofĀ 44+1=45Ā attacks.
Test caseĀ 4:Ā Chef can use the special attack to immediately bring the health of the boss to zero, hence only needing one attack.
SOLUTION
Here Discuss About Solve Single-use Attack CodeChef Solution
SOLUTION
Single-use Attack CodeChef Solution
SOLUTION
Yhaa You have done it but next? if YOU Want to Get Others Please Visit HereĀ ScishowEngineerĀ Ā ThenĀ Follow US HEREĀ andĀ Join Telegram.
If You Want To Learn Something New Then Visit OurĀ Official Channel YOUTUBE