atcoder#YAHOOPROCON2019QUALC. When I hit my pocket...

When I hit my pocket...

Score : 400400 points

Problem Statement

Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly KK times in total, in the order he likes:

  • Hit his pocket, which magically increases the number of biscuits by one.
  • Exchange AA biscuits to 11 yen.
  • Exchange 11 yen to BB biscuits.

Find the maximum possible number of biscuits in Snuke's pocket after KK operations.

Constraints

  • 1K,A,B1091 \leq K,A,B \leq 10^9
  • K,AK,A and BB are integers.

Input

Input is given from Standard Input in the following format:

KK AA BB

Output

Print the maximum possible number of biscuits in Snuke's pocket after KK operations.

4 2 6
7

The number of biscuits in Snuke's pocket after KK operations is maximized as follows:

  • Hit his pocket. Now he has 22 biscuits and 00 yen.
  • Exchange 22 biscuits to 11 yen. his pocket. Now he has 00 biscuits and 11 yen.
  • Hit his pocket. Now he has 11 biscuits and 11 yen.
  • Exchange 11 yen to 66 biscuits. his pocket. Now he has 77 biscuits and 00 yen.
7 3 4
8
314159265 35897932 384626433
48518828981938099