luogu#P4669. [BalticOI 2011 Day2] Meetings

[BalticOI 2011 Day2] Meetings

题目描述

The Society for Saving the World has called their NN 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:

  1. Each of them has a proposal and takes PP minutes to present it to the others.

  2. After all participants have made their presentations, they vote for the best proposal, which takes VV minutes.

For example, if each proposal takes one minute (P=1)(P = 1) and voting also takes one minute (V=1)(V = 1), a meeting with 100100 participants would reach a decision in 101101 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 100100 participants would split into two groups of 4040 and 6060, respectively, the process could work as follows (again, P=V=1P = V = 1):

  • the larger group takes 6161 minutes to select their best proposal;
  • the smaller group takes 4141 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 22 minutes presenting to each other and 11 minute to vote.

The total time spent is thus 61+2+1=6461 + 2 + 1 = 64 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 11 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 PP and VV , computes the minimal time needed for the NN participants of the congress to reach a common decision, assuming they organize their meetings and groups optimally.

输入格式

The first and only line of input contains the three integers N,P,N, P, and VV : NN is the number of participants of the congress, PP is the presentation time (in minutes), and VV is the voting time (in minutes).

输出格式

The first and only line of output should contain the integer MM, the minimal number of minutes needed for the congress to reach a decision.

题目大意

** 译自 BalticOI 2011 Day2 T1「Meetings」**

NN 人需达成一项计划。每人都花 PminP\min 陈述自己的提案,所有人陈述完毕后再花 VminV\min 表决出最佳提案。例如,如果有 100100 人,P=V=1minP=V=1\min,总共需要 1×100+1=101min1\times 100 + 1=101\min 来达成计划。
为了加快进度,他们想分成小组,每个小组表决出一份最佳议案,再由全部人一起表决各小组选出的议案。注意小组内可以再分组。小组内表决的方式类似,也是每人陈述自己的提案后再表决。例如,100100 人分成两组,一组 6060 人,一组 4040 人,那么过程如下(与前面相同,P=V=1minP=V=1\min):

  • 6060 人组花 61min61\min 选出最佳议案,同时 4040 人组花 41min41\min 选出最佳议案(自然,他们要等待 6060 人组);
  • 两组再花 2min2\min 陈述,然后花 1min1\min 表决。

总用时 61+2+1=64min61 + 2 + 1 = 64\min
试求:他们至少要多久才能达成计划。

Translated by @Planet6174

9 1 1
8
6 1 2
8
6 2 1
12

提示

Sample Explanation 1

In sample 1,the nine people should be divided into 3 groups.There should be 3 people in each group.

数据范围

对于 40%40\% 的数据,1N50001 \le N \le 5000

对于 70%70\% 的数据,1N5×1041 \le N \le 5 \times 10^4

对于所有数据,1N1015,1P,V10001 \le N \le 10^{15},1 \le P,V \le 1000