#P11063. 【MX-X4-T3】「Jason-1」数对变换
【MX-X4-T3】「Jason-1」数对变换
Background
Original problem link: https://oier.team/problems/X4D.
Problem Description
For a pair of positive integers , define one transformation as follows: choose one number , let the other number be , and at the same time choose a positive integer . Then divide by and take the floor, and multiply by .
Formally, for the pair , you may perform the following two types of transformations:
- Type 1: choose , set $(x,y) \gets (\lfloor \frac{x}{k} \rfloor, y \cdot k)$.
- Type 2: choose , set $(x,y) \gets (x \cdot k, \lfloor \frac{y}{k} \rfloor)$.
Obviously, the resulting pair is still a pair of positive integers.
Given two pairs of positive integers and , you need to perform no more than transformations to change into , or report that there is no solution. Note: you do not need to minimize the number of transformations.
Note that the pair is ordered, i.e., if , then .
This problem uses a custom checker to verify whether your answer is correct, so if there are multiple valid solutions, you only need to output any one of them.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , the number of test cases. For each test case:
- One line with four positive integers , representing the two pairs.
Output Format
For each test case:
- If there is no solution,
- output one line with the string
-1.
- output one line with the string
- Otherwise,
- the first line contains a non-negative integer , the number of transformations you perform. You must ensure , but you do not need to minimize .
- The next lines: the -th line contains two integers , representing the -th transformation. Here indicates the transformation type, and is the chosen in this transformation.
This problem uses a custom checker to verify whether your answer is correct, so if there are multiple valid solutions, you only need to output any one of them.
7
1 1 1 1
1 2 1 1
2 2 1 2
10 10 2 50
5 5 4 10
80 43 52 64
987654321 123456789 313814116 388538872
0
-1
3
1 2
2 3
1 2
1
1 5
-1
2
1 3
2 2
2
1 31415
2 9982
Hint
[Sample Explanation]
For test case 1, no operation is needed because initially and .
For test case 2, it can be proven that there is no solution.
For test case 3, after the first transformation , after the second transformation , and after the third transformation .
For test case 4, one transformation is enough to make and .
For test case 5, it can be proven that there is no solution.
For test case 6, after the first transformation , and after the second transformation .
For test case 7, after the first transformation , and after the second transformation .
[Constraints]
This problem uses bundled testdata.
Let .
| Subtask | Special Property | Score | |
|---|---|---|---|
| 1 | None | ||
| 2 | A | ||
| 3 | C | ||
| 4 | B | ||
| 5 | C | ||
| 6 | None |
- Special Property A: guaranteed .
- Special Property B: guaranteed and .
- Special Property C: guaranteed that are generated independently and uniformly at random within the value range.
For of the testdata, , .
Translated by ChatGPT 5