Magic Pocket SOLUTIONS SC_04 CODECHEF

Page Contents

Magic Pocket SOLUTIONS SC_04 CODECHEF

Problem Statement

Harry Potter has one roll and zero rupee in his pocket. He will play out the accompanying activities precisely K times altogether, in the request he prefers:

Hit his pocket, which mysteriously expands the quantity of bread rolls by one.

Trade A scones to 1 rupee.

Trade 1 rupee to B scones.

Locate the greatest conceivable number of scones in Harry’s pocket after K tasks.

Info

Info is given in the accompanying organization:

K A B

Yield

Prit the greatest conceivable number of scones in Harry’s pocket after Koperations.

Limitations

1≤K,A,B≤109

K, An and are numbers.

Test Input

4 2 6

Test Output

Clarification

The quantity of scones in Harry’s pocket after K activities is amplified as follows:

Hit his pocket. Presently he has 2 scones and 0 rupee.

Trade 2 scones to 1 rupee in his pocket .Now he has 0 rolls and 1 rupee.

Hit his pocket. Presently he has 1 scones and 1 rupee.

Trade 1 rupee to 6 bread rolls. his pocket. Presently he has 7 rolls and 0 rupee.