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.
Definition
- Class:
- FightMonsterDiv2
- Method:
- damageDealt
- Parameters:
- long, long, long
- Returns:
- long
- Method signature:
- long damageDealt(long attack, long level, long duration)
- (be sure your method is public)
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.
Examples
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
100
100
100000
Returns: 500005000000
100000
0
100000
Returns: 10000000000
5200
10
11
Returns: 85800
3000
7
12
Returns: 49860
4600
8
14
Returns: 97888
900
9
20
Returns: 33390
100
6
11
Returns: 1430
79200
55
50839
Returns: 56295592574760
33400
97
95641
Returns: 148177152192160
64300
59
57602
Returns: 62939912163337
75200
49
58010
Returns: 62003003258160
64200
85
85850
Returns: 201099690065250
200
10
2
Returns: 420
200
1
2
Returns: 402
200
3
2
Returns: 406
200
10
3
Returns: 660
400
2
1000
Returns: 4396000
300
5
10
Returns: 3675
500
5
3
Returns: 1575