#P7325. [WC2021] 斐波那契
[WC2021] 斐波那契
Description
As everyone knows, student Xiaocong is good at calculations, especially at computing binomial coefficients. But after studying binomial coefficients thoroughly, Xiaocong lost interest in them and started researching sequences.
We define , , and ().
Now you are given queries. For each query, find the smallest integer such that .
Input Format
The first line contains two integers , representing the number of queries and the modulus used in each computation.
The next lines each contain two integers , representing the values of and in one query.
Output Format
For each query, output one integer on a single line as the answer. If such a does not exist, output -1.
4 5
0 1
1 2
2 3
3 4
0
3
2
-1
1 6
4 4
3
见附件中的 fib/fib3.in
见附件中的 fib/fib3.ans
见附件中的 fib/fib4.in
见附件中的 fib/fib4.ans
Hint
Constraints
For all testdata: , .
The specific limits for each test point are shown in the table below:
| Test Point ID | Special Constraints | |
|---|---|---|
| None. | ||
| is prime. | ||
| , where the are pairwise distinct primes. | ||
| None. |
Translated by ChatGPT 5
京公网安备 11011102002149号