#P1069. [NOIP 2009 普及组] 细胞分裂
[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 types of cells, numbered from . A type cell can split into cells of the same type after second ( 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 test tubes to form samples for the experiment. The number of test tubes is very large, so ordinary computer primitive data types cannot store it. Fortunately, can always be expressed as the -th power of , i.e., , where 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 cells in the dish, Dr. Hanks can distribute them into test tubes with cells per tube, and then start the experiment. But if there are cells, he cannot evenly divide them into 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 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 , the number of cell types.
- The second line contains two positive integers separated by a space, representing the total number of test tubes .
- The third line contains positive integers. The -th number indicates that a type cell becomes cells of the same type after 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
2 1
3
-1
2
24 1
30 12
2
Hint
Explanation for Sample Input/Output #1:
After second, the cells split into ; after seconds, they split into ; … It can be seen that the number of cells is always odd, so they can never be evenly divided into test tubes.
Explanation for Sample Input/Output #2:
For the first type of cell, the earliest time to be evenly divided into test tubes is after seconds, while for the second type it is already possible after seconds (each test tube gets cells). Therefore, the earliest time to start the experiment is after seconds.
Constraints:
- For of the testdata, .
- For all the testdata, , , , .
NOIP 2009 Junior, Problem 3.
Translated by ChatGPT 5
京公网安备 11011102002149号