#P15240. [NHSPC 2025] 解碼密鑰
[NHSPC 2025] 解碼密鑰
Problem Description
In a video game, a supercomputer called the “Central Core” controls the operation of the entire city. However, recently the Central Core was locked by a firewall made of malicious code, and the city has fallen into paralysis.
To break this firewall, you must enter a specific “unlock code”. This unlock code is not a simple number, but the -th “valid number”. The city has special servers, and the -th server comes with a unique key . Any positive integer that is divisible by at least one of these keys can be considered a “valid number”.
Given and , your task is to find the -th “valid number”, use it as the unlock code, and enter it into the “Central Core” to save the city.
For example, if , , and the keys are , then the numbers divisible by , , or are, in order, . The -th number is , so the answer is .
Input Format
$$\begin{aligned} &n \; k \\ &p_1 \; p_2 \; \dots \; p_k \end{aligned}$$- means you need to find the -th valid number.
- means the number of keys.
- means the value of the -th key.
Output Format
- Output a positive integer , representing the -th number that is divisible by at least one number among .
10 3
2 3 5
14
5 2
4 6
16
1000000000 4
1806 1110 600 777767777
325960839000
Hint
Constraints
- .
- 。
- $1 \le p_1\times p_2\times\cdots\times p_k \le 10^{18}$。
- It is guaranteed that the required answer is .
- All input numbers are integers.
Scoring
This problem has four subtasks with the following constraints. Each subtask may contain one or more testdata files, and you will get the score for a subtask only if you answer all testdata in that subtask correctly.
| Subtask | Score | Additional Input Constraints |
|---|---|---|
| 1 | 2 | It is guaranteed that the required answer is 。 |
| 2 | 27 | 。 |
| 3 | 34 | 。 |
| 4 | 37 | No additional constraints. |
Translated by ChatGPT 5