#abc260c. C - Changing Jewels

C - Changing Jewels

Score : 300300 points

问题陈述

Takahashi 拥有一颗等级为 NN 的红宝石。(他没有其他宝石。)
Takahashi 可以任意多次进行以下操作。

  • 将一颗等级为 nnnn 至少为 22)的红宝石转换为“一颗等级为 (n1)(n-1) 的红宝石和 XX 颗等级为 nn 的蓝宝石”。
  • 将一颗等级为 nnnn 至少为 22)的蓝宝石转换为“一颗等级为 (n1)(n-1) 的红宝石和 YY 颗等级为 (n1)(n-1) 的蓝宝石”。

Takahashi 希望获得尽可能多的等级为 11 的蓝宝石。通过这些操作,他最多可以获得多少颗等级为 11 的蓝宝石?

以上为通义千问 qwen-max 翻译,仅供参考。

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.

Sample Input 1

2 3 4

Sample Output 1

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.

Sample Input 2

1 5 5

Sample Output 2

0

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

Sample Input 3

10 5 5

Sample Output 3

3942349900

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

update @ 2024/3/10 11:01:19