Baltic Olympiad in Informatics: 2011 Day 2, Problem 1
The Society for Saving the World has called their members to an emergency congress to finally
agree on a plan for saving the world. To reach a common decision in any meeting at the congress, the
meeting participants proceed as follows:
Each of them has a proposal and takes
minutes to present it to the others.
After all participants have made their presentations, they vote for the best proposal, which takes
minutes.
For example, if each proposal takes one minute () and voting also takes one minute (
), a
meeting with
participants would reach a decision in
minutes.
To speed up the overall decision-making process, the participants of the congress have decided to split into groups and work in parallel. Each group selects the best proposal among themselves using the procedure described above. Then the representatives of the groups meet and pick the final plan among the proposals voted best in each group.
For example, if the participants would split into two groups of
and
, respectively, the process
could work as follows (again,
):
- The larger group takes
minutes to select their best proposal;
- The smaller group takes
minutes to do the same and then has to wait for the larger group to finish;
- Then the two representatives of the groups meet and spend
minutes presenting to each other and
minute to vote.
The total time spent is thus minutes.
But the groups might further divide themselves into subgroups and sometimes it could be useful to
split into more than two groups. As a special case, a subgroup of member can decide in no time, as
there is no need to present one's own proposal to oneself.
Write a program that, given presentation and voting times and
, computes the minimal time
needed for the
participants of the congress to reach a common decision, assuming they organize
their meetings and groups optimally.
Constraints
Subtask 1 [40%]
Subtask 2 [30%]
Subtask 3 [30%]
No additional constraints.
Input Specification
The first and only line of input contains the three space-separated integers ,
, and
, where
is the number of participants of the congress,
is the presentation time (in minutes), and
is the voting time (in minutes).
Output Specification
The first and only line of output should contain the integer , the minimal number of minutes needed
for the congress to reach a decision.
Sample Input 1
9 1 1
Sample Output 1
8
Explanation for Sample 1
In this example, the participants can be divided into groups of
members each. Then each group
needs
minutes and the
representatives need another
minutes for their final meeting.
Sample Input 2
6 1 2
Sample Output 2
8
Sample Input 3
6 2 1
Sample Output 3
12
Comments