atcoder#ABC260C. [ABC260C] Changing Jewels
[ABC260C] Changing Jewels
Score : points
Problem Statement
Takahashi has a red jewel of level . (He has no other jewels.) Takahashi can do the following operations any number of times.
- Convert a red jewel of level ( is at least ) into "a red jewel of level and blue jewels of level ".
- Convert a blue jewel of level ( is at least ) into "a red jewel of level and blue jewels of level ".
Takahashi wants as many blue jewels of level as possible. At most, how many blue jewels of level can he obtain by the operations?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 3 4
12
Takahashi can obtain blue jewels of level by the following conversions.
- First, he converts a red jewel of level into a red jewel of level and blue jewels of level .- After this operation, Takahashi has red jewel of level and blue jewels of level .
- Next, he repeats the following conversion times: converting a blue jewel of level into a red jewel of level and blue jewels of level .- After these operations, Takahashi has red jewels of level and blue jewels of level .
- He cannot perform a conversion anymore.
He cannot obtain more than blue jewels of level , so the answer is .
1 5 5
0
Takahashi may not be able to obtain a blue jewel of level .
10 5 5
3942349900
Note that the answer may not fit into a -bit integer type.