Question
Task Sprint

Ram is tackling N school assignment problems. He works until solving at least half the remaining problems before taking a break: for even N, after N/2 problems; for odd N, after (N + 1)/2. Each break lasts B minutes. Initially, Ram takes M minutes per problem, doubling to 2 x M after each break. Calculate the total time to complete the assignment.

Input
The only line of input contains Three space-separated integers N, B, M.

Constraints
1 ≤ N, B, M ≤ 107
Output
Return how much time Ram will need (in minutes) for completing the assignment.
Example
Sample Input
9 1 2
Sample Output
45
Explanation
In the first test case, Ram will proceed as below:
-> Initially, Ram has 9 problems to solve. since it is an odd number, Ram will finish the first (9 + 1) / 2 = 5 problems with speed of 2 minutes/problem.
-> After that, Ram takes 1 minute break.
-> Now he has 4 problems to solve, which is an even number, so Ram will solve the next 4 / 2 = 2 problems. his speed after the first break has now became 4 minutes/problem.
-> Again, he takes a 1 minute break.
-> He has now 2 problems left so he do one more problem in 8 minutes.
-> He takes 1 minute break.
-> he solves the last problem in 16 minutes.
So, Ram will need time = 5 × 2 + 1 + 2 × 4 + 1 + 8 + 1 + 16 = 45

Online