FightMonsterDiv2
TCO19 SRM 749 · 2019-01-09 · by Blue.Mary
Problem Statement
Hero is fighting against a monster.
Hero's basic attack deals attack points of damage. Hero also has a special skill that gradually increases the amount of damage he deals when attacking the same monster multiple times in a row. Hero has level skill points in this skill. The effect of the skill is such that in each of the following attacks the damage is increased by level percent of the damage dealt by the basic attack. In other words, if Hero already attacked the monster n times, the next attack after that will deal attack + n * (level percent of attack) damage.
Hero is going to attack the monster duration times in a row. Calculate and return the total amount of damage he will deal.
Constraints
- attack will be between 100 and 100,000, inclusive.
- attack will be a multiple of 100.
- level will be between 0 and 100, inclusive.
- duration will be between 1 and 100,000, inclusive.
100 10 3 Returns: 330
The first attack will deal 100 damage. The second attack will deal 100 + 10 = 110 damage. The third attack will deal 110 + 10 = 120 damage.
100 0 5 Returns: 500
With level = 0, the increment is zero and thus each of the five attacks will deal 100 damage.
100000 100 100000 Returns: 500005000000000
This is the largest possible input. Watch out for integer overflow.
100 0 1 Returns: 100
100 100 1 Returns: 100
Submissions are judged against all 24 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FightMonsterDiv2 with a public method long long damageDealt(long long attack, long long level, long long duration) · 24 test cases · 2 s / 256 MB per case