100 atcoder#ABC180D. [ABC180D] Takahashi Unevolved
[ABC180D] Takahashi Unevolved
Score : points
Problem Statement
Iroha is into a game where you keep pets.
Iroha's pet is Takahashi. Initially, Takahashi's STR and EXP are and , respectively. These parameters increase in the following two kinds of training:
- Go to Kakomon Gym: the STR gets multiplied by , and the EXP increases by .
- Go to AtCoder Gym: the STR increases by , and the EXP increases by .
Takahashi evolves when his STR becomes or greater, but Iroha thinks that makes him less cute.
Find the maximum possible EXP of Takahashi when he is trained without letting him evolve.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible EXP of Takahashi under the given situation.
4 20 2 10
2
Initially, Takahashi's STR is . We can make his EXP in the following course of training:
- First, go to Kakomon Gym, which makes his STR and his EXP .
- Then, go to AtCoder Gym, which makes his STR and his EXP .
On the other hand, there is no way to train him so that his EXP becomes greater than .
1 1000000000000000000 10 1000000000
1000000007
Watch out for overflows.