#P11130. 【MX-X5-T2】「GFOI Round 1」Interstellar
【MX-X5-T2】「GFOI Round 1」Interstellar
Background
Original problem link: https://oier.team/problems/X5C.
Problem Description
You have a positive integer , and you may perform the following operation on it:
- Choose a positive integer , and change to times itself, i.e., .
(Here, denotes the greatest common divisor of and .)
The initial value of is . You want to turn it into using some number of operations (possibly zero). You want to know the minimum number of operations needed to achieve the goal, or report that it is impossible.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , indicating the number of test cases.
For each test case:
The first line contains two positive integers .
Output Format
For each test case:
- If it is impossible, i.e., no matter how you operate, can never become , output .
- Otherwise, output a single non-negative integer on one line, representing the minimum number of operations.
6
1 1
2 4
2 6
12 288
30 144000
114 5141919810
0
1
-1
2
3
-1
Hint
Sample Explanation
For the first test case, no operation is needed, so the answer is .
For the second test case, you can choose , then becomes .
For the third test case, it is easy to prove that no matter what operations you do, you cannot achieve the goal, so output .
For the fourth test case, you can:
- Choose , then becomes .
- Choose , then becomes .
Constraints
| Test Point ID | Score | ||
|---|---|---|---|
For all test cases, , .
Translated by ChatGPT 5