#P8357. 「WHOI-1」Derives

    ID: 9318 远端评测题 1600ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP数论Special JudgeO2优化记忆化搜索

「WHOI-1」Derives

Background

One counterfeit coin has been mixed into your money.

Problem Description

You have nn coins. After accurate measurement, you find that there must be exactly one counterfeit coin, and its mass is different from the other coins. You want to find this counterfeit coin.

In round ii, suppose you currently have xix_i coins. You will divide all the coins into several groups, with kik_i coins in each group, and put the remaining coins (if any) into one additional group. Picking up each coin takes aa seconds, so this will take axia x_i seconds. Next, you will weigh each group. Weighing one group takes bb seconds, so this will take bxikib\cdot\left\lceil\frac{x_i}{k_i}\right\rceil seconds. Since there is only one counterfeit coin, only one group will have a mass different from the normal mass. After weighing all groups, you will select the group whose mass is different from the normal mass and enter the next round, letting xi+1=kix_{i+1}=k_i. You keep doing this until xi=1x_i=1. Suppose there are mm rounds in total, then the total time is

$$f=\sum\limits_{i=1}^{m}{\left(ax_i+b\cdot\left\lceil\frac{x_i}{k_i}\right\rceil\right)}.$$

In the worst case (that is, in every round the abnormal group is always a group of kik_i coins), what is the minimum time needed to find the counterfeit coin?

Input Format

One line with three positive integers, representing n,a,bn,a,b.

Output Format

The first line contains two non-negative integers f,mf,m, representing the minimum possible time and the number of rounds in your plan.

The next line contains mm positive integers, representing kik_i.

20 1 3
51 2
4 1
1000 10 100
13570 4
72 12 3 1

Hint

Explanation

You should try your best to make the total time as small as possible.

This problem uses Special Judge.

First, the answer you output must be valid, i.e. your output must match the selection method described above, otherwise you will get 00 points.

Then, the judge will evaluate your output. If your output is valid and its difference from the correct answer is 9\le9, you will get a score of (10d)×100%(10-d)\times100\%. For example, if the difference between your output and the correct answer is 44, you will get 60%60\%. If your output equals the correct answer, you will get 100%100\%. Please do not output extra numbers or output fewer numbers than required.

Constraints

  • subtask 1(10pts):\text{subtask 1(10pts)}: 1n20001\le n\le2000.
  • subtask 2(20pts):\text{subtask 2(20pts)}: 1n750001\le n\le75000.
  • subtask 3(30pts):\text{subtask 3(30pts)}: 1n1071\le n\le10^7.
  • subtask 4(40pts):\text{subtask 4(40pts)}: 1n1091\le n\le10^9.

For all testdata, 0<a,b1090<a,b\le10^9.

Sample Explanation

For the first sample, there are two rounds. x1=20,k1=4,x2=4,k2=1x_1=20,k_1=4,x_2=4,k_2=1. The answer is f=20+15+4+12=51f=20+15+4+12=51.

Translated by ChatGPT 5