atcoder#ABC260C. [ABC260C] Changing Jewels

[ABC260C] Changing Jewels

Score : 300300 points

Problem Statement

Takahashi has a red jewel of level NN. (He has no other jewels.) Takahashi can do the following operations any number of times.

  • Convert a red jewel of level nn (nn is at least 22) into "a red jewel of level (n1)(n-1) and XX blue jewels of level nn".
  • Convert a blue jewel of level nn (nn is at least 22) into "a red jewel of level (n1)(n-1) and YY blue jewels of level (n1)(n-1)".

Takahashi wants as many blue jewels of level 11 as possible. At most, how many blue jewels of level 11 can he obtain by the operations?

Constraints

  • 1N101 \leq N \leq 10
  • 1X51 \leq X \leq 5
  • 1Y51 \leq Y \leq 5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN XX YY

Output

Print the answer.

2 3 4
12

Takahashi can obtain 1212 blue jewels of level 11 by the following conversions.

  • First, he converts a red jewel of level 22 into a red jewel of level 11 and 33 blue jewels of level 22.- After this operation, Takahashi has 11 red jewel of level 11 and 33 blue jewels of level 22.
  • Next, he repeats the following conversion 33 times: converting a blue jewel of level 22 into a red jewel of level 11 and 44 blue jewels of level 11.- After these operations, Takahashi has 44 red jewels of level 11 and 1212 blue jewels of level 11.
  • He cannot perform a conversion anymore.

He cannot obtain more than 1212 blue jewels of level 11, so the answer is 1212.

1 5 5
0

Takahashi may not be able to obtain a blue jewel of level 11.

10 5 5
3942349900

Note that the answer may not fit into a 3232-bit integer type.