Back
Close

Gold rush

Statement

 Goal

Machines produce gold.
Every machine costs C gold to buy and then produces P gold per turn, starting the next turn after it is bought.
You start at turn 0 with 1 machine and 0 gold. You can buy as many machines as you can afford.
What is the maximum amount of gold you can reach at turn 100?

Ex: C = 10 and P = 1
At turn 1 you have 1 gold ... 2 gold at turn 2 ... 3 gold at turn 3...
If you buy another machine at turn 10, you end up with 0 gold at turn 10 (because you spent 10)
At turn 11 you'll have 2 gold (because both machines produce 1)
Producing 2 gold from turn 11 to 100, you'll end up with 180 gold. But you can certainly do better...
Input
Line 1: C, the cost of each machine
Line 2: P, the gold per turn production of each machine
Output
Line 1: The max amount of gold you can have at turn 100.
Constraints
0 < C < 100
0 < P < 100
Example
Input
10
1
Output
32904

Game modes
Fastest, Shortest

Test cases
Profitable Test
Input
10 1
Output
32904

Validator 1 Validator
Input
11 1
Output
15314

Hardly profitable Test
Input
99 2
Output
201

Validator 2 Validator
Input
98 2
Output
204

Not profitable Test
Input
50 1
Output
100

Validator 3 Validator
Input
51 1
Output
100

Very profitable Test
Input
43 7
Output
36299177

Validator 4 Validator
Input
71 9
Output
2652774

Solution language

Solution

Stub generator input