Time limit
1s
Memory limit
128 MB
In 2012, Earth is about to end. To protect it, the emergency council of the superpower Safari World has been called. The council has N members, and they must choose one final opinion.
If a direct meeting has k participants, it takes the following time.
P minutes.V minutes.Therefore, when k >= 2, a direct meeting takes k * P + V minutes. If there is only one participant, there is already only one opinion, so no time is needed.
To make the decision faster, the members may be divided into several groups. All groups meet at the same time and each group chooses one representative opinion. After every group has finished, only the people who gave those representative opinions meet again by the same rules. A group may also be divided into smaller groups recursively, and the process continues until one final opinion remains.
Given N, P, and V, find the minimum time needed to obtain one final opinion when the groups are chosen optimally.
The first line contains three integers N, P, and V.
Print the minimum time M needed for the council to obtain one final opinion.
1 <= N <= 10^151 <= P, V <= 1 000In the first visible test, the 9 members can be divided into 3 groups of 3. Each group meeting takes 4 minutes, and then the 3 representatives meet for another 4 minutes, for a total of 8 minutes.