Question
School Assignment
Jack has got N problems in the assignmen from school. Jack will not take a break until he finishes at least half of the remaining problems. Formally, if N is even then he will take he first break after finishing N / 2 problems. If N is odd then the break will be after he done (N + 1) / 2 problems. Each of his break will last for B minutes. Initially, he takes M minutes in solving a problem, after each break he will take twice more time in solving a problem, i.e. 2 * M minutes per problem after the first break.
You need to help Jack and calculate how much time it will take until he finish the assignment.
Input
The only line of input contains Three space-separated integers N, B, M.
Output
Return how much time Jack will need (in minutes) for completing the assignment.
Example
Sample Input:
9 1 2
Sample Output:
45
Explanation
In the first test case, Jack will proceed as below:

-> Initially, Jack has 9 problems to solve. since it is an odd number, Jack will finish the first (9 + 1) / 2 = 5 problems with speed of 2 minutes/problem.
-> After that, Jack takes 1 minute break.
-> Now he has 4 problems to solve, which is an even number, so Jack 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, Jack will need time = 5 × 2 + 1 + 2 × 4 + 1 + 8 + 1 + 16 = 45

Online