#P6690. 一次函数
一次函数
Problem Description
You are given linear functions , where is a placeholder of a formal power series.
Choose functions from these functions (). Define the set as the set of values obtained by taking a product of some powers of modulo . That is:
$$H=\left\{\prod_{i=1}^k g_i(x)^j\bmod x^2\middle|0 \leq a, b < p \right\}$$Here, can be any non-negative integer, and different may use different .
Note that is always in the set (not ). This is true even when .
Given , find the minimum among all sets such that .
If no such exists with , output -1.
All operations are performed modulo .
Input Format
The first line contains four integers .
The next lines each contain two integers .
Output Format
The first line contains one integer , which is the answer.
If a solution exists, then the next lines each contain two integers , and they must satisfy:
The order of can be arbitrary.
1 997 603 648
200 61
1
1 140787
1 953 712 307
534 750
-1
3 7 6 5
3 4
5 6
4 6
2
2 5
1 20
Hint
There are also two large sample tests and a checker. The download link is in the attachments.
To test your answer for a certain test case, you need to run the following command in the command line under this problem directory:
<checker> <input‐file> <output‐file> <answer‐file> [<report‐file>]
Where:
<checker>is the executable file of the checker;<input‐file>is the input file of that test case, such asfunc1.in;<output‐file>is your output file for that test case, such asfunc1.out;<answer‐file>is the answer file of that test case (you only need to provide the first line of the output), such asfunc1.ans;<report‐file>is an optional parameter. If it is not given, the checker will output to the terminal; otherwise, it will output to that file, such asreport1.txt.
Constraints: for all data, . It is guaranteed that is a prime. , , .
The detailed constraints and notes are as follows (blank means the same as the constraints above):
| Subtask ID | Score | Special Property | ||
|---|---|---|---|---|
Translated by ChatGPT 5