#P6197. [EER1] 礼物
[EER1] 礼物
Description
Xiao Z gave you a sequence. Specifically, , , and , where is the length of the sequence, and is a positive integer parameter she set.
Xiao Z told you a secret: this sequence was carefully chosen by her and has a wonderful property called "Prime-smooth"—that is, for any prime not exceeding , it holds that ( denotes divisibility).
You were curious whether this was really true, so you wrote a prime generator and tried for three days and three nights. Finally, you found a few counterexamples: there are primes that do not satisfy the property Xiao Z mentioned.
Since you have randomized for a long time, you believe that other primes must satisfy the property.
To show that you and Xiao Z think alike, you now want to guess the parameter that Xiao Z set back then. Since the answer is very large, you only need to output the minimum modulo a prime .
Input Format
The first line contains three non-negative integers , with the same meanings as in the statement.
The next lines each contain a positive integer , meaning that the -th prime in increasing order, , does not satisfy . We guarantee that this prime . Note: it is not guaranteed that these numbers are pairwise distinct.
Output Format
Output one integer: the value of the minimum modulo .
In particular, if there is no solution, output .
10 1 998244353
3
20
40 2 1018429441
1
4
-1
Hint
Sample 1 Explanation
Note that the 3rd prime is .
When , , , and all satisfy , and satisfies .
Constraints
.
, , and it is guaranteed that is prime.
.
| Subtask ID | Special Property | Score | ||
|---|---|---|---|---|
| 1 | 10 | |||
| 2 | 20 | |||
| 3 | 10 | |||
| 4 | ||||
| 5 | 20 | |||
| 6 | ||||
| 7 | 10 |
Translated by ChatGPT 5
京公网安备 11011102002149号