#P1069. [NOIP 2009 普及组] 细胞分裂

    ID: 69 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2009NOIp 普及组素数判断,质数,筛法

[NOIP 2009 普及组] 细胞分裂

Description

Dr. Hanks is a renowned expert in BT (Bio-Tech, 生物技术). He is preparing for a cell experiment: culturing cell samples.

Dr. Hanks currently has NN types of cells, numbered from 1N1 \sim N. A type ii cell can split into SiS_i cells of the same type after 11 second (SiS_i is a positive integer). He needs to select one cell of some type, put it into a Petri dish, and let it divide freely for culturing. After some time, he will evenly distribute all cells in the dish into MM test tubes to form MM samples for the experiment. The number of test tubes MM is very large, so ordinary computer primitive data types cannot store it. Fortunately, MM can always be expressed as the m2m_2-th power of m1m_1, i.e., M=m1m2M = m_1^{m_2}, where m1,m2m_1, m_2 are both positive integers storable in primitive data types.

Note that splitting a single cell is not allowed during the entire experiment. For example, if at some moment there are 44 cells in the dish, Dr. Hanks can distribute them into 22 test tubes with 22 cells per tube, and then start the experiment. But if there are 55 cells, he cannot evenly divide them into 22 test tubes. In that case, he must either wait for a while for further division so that the count becomes divisible, or switch to culturing another cell type.

To start the experiment as early as possible, once he has fixed a cell type to culture, he always stops culturing and starts the experiment at the first moment when the number of cells can be evenly divided into MM test tubes. Now he wants to know which cell type to culture so that the experiment can start at the earliest time.

Input Format

  • The first line contains a positive integer NN, the number of cell types.
  • The second line contains two positive integers m1,m2m_1, m_2 separated by a space, representing the total number of test tubes M=m1m2M = m_1^{m_2}.
  • The third line contains NN positive integers. The ii-th number SiS_i indicates that a type ii cell becomes SiS_i cells of the same type after 11 second.

Output Format

Output a single integer: the minimum time in seconds from the start of culturing to the moment the experiment can begin.

If no choice of cell type can satisfy the requirement, output 1-1.

1 
2 1 
3

-1

2
24 1
30 12

2

Hint

Explanation for Sample Input/Output #1:

After 11 second, the cells split into 33; after 22 seconds, they split into 99; … It can be seen that the number of cells is always odd, so they can never be evenly divided into 22 test tubes.

Explanation for Sample Input/Output #2:

For the first type of cell, the earliest time to be evenly divided into 2424 test tubes is after 33 seconds, while for the second type it is already possible after 22 seconds (each test tube gets 144/241=6144 / {24}^1 = 6 cells). Therefore, the earliest time to start the experiment is after 22 seconds.

Constraints:

  • For 50%50\% of the testdata, m1m230000m_1^{m_2} \le 30000.
  • For all the testdata, 1N100001 \le N \le 10000, 1m1300001 \le m_1 \le 30000, 1m2100001 \le m_2 \le 10000, 1Si2×1091 \le S_i \le 2 \times 10^9.

NOIP 2009 Junior, Problem 3.

Translated by ChatGPT 5