Changing Jewels

AtCoder
IDabc260_c
Time2000ms
Memory256MB
Difficulty
Takahashi has a red jewel of level $N$. (He has no other jewels.) Takahashi can do the following operations any number of times. * Convert a red jewel of level $n$ ($n$ is at least $2$) into "a red jewel of level $(n-1)$ and $X$ blue jewels of level $n$". * Convert a blue jewel of level $n$ ($n$ is at least $2$) into "a red jewel of level $(n-1)$ and $Y$ blue jewels of level $(n-1)$". Takahashi wants as many blue jewels of level $1$ as possible. At most, how many blue jewels of level $1$ can he obtain by the operations? ## Constraints * $1 \leq N \leq 10$ * $1 \leq X \leq 5$ * $1 \leq Y \leq 5$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $X$ $Y$ [samples]
Samples
Input #1
2 3 4
Output #1
12

Takahashi can obtain $12$ blue jewels of level $1$ by the following conversions.

*   First, he converts a red jewel of level $2$ into a red jewel of level $1$ and $3$ blue jewels of level $2$.
    *   After this operation, Takahashi has $1$ red jewel of level $1$ and $3$ blue jewels of level $2$.
*   Next, he repeats the following conversion $3$ times: converting a blue jewel of level $2$ into a red jewel of level $1$ and $4$ blue jewels of level $1$.
    *   After these operations, Takahashi has $4$ red jewels of level $1$ and $12$ blue jewels of level $1$.
*   He cannot perform a conversion anymore.

He cannot obtain more than $12$ blue jewels of level $1$, so the answer is $12$.
Input #2
1 5 5
Output #2
0

Takahashi may not be able to obtain a blue jewel of level $1$.
Input #3
10 5 5
Output #3
3942349900

Note that the answer may not fit into a $32$\-bit integer type.
API Response (JSON)
{
  "problem": {
    "name": "Changing Jewels",
    "description": {
      "content": "Takahashi has a red jewel of level $N$. (He has no other jewels.)   Takahashi can do the following operations any number of times. *   Convert a red jewel of level $n$ ($n$ is at least $2$) into \"a r",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc260_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Takahashi has a red jewel of level $N$. (He has no other jewels.)  \nTakahashi can do the following operations any number of times.\n\n*   Convert a red jewel of level $n$ ($n$ is at least $2$) into \"a r...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments