luogu#P7847. 「dWoi R2」Elevator / 电梯

「dWoi R2」Elevator / 电梯

Background

Zszz, the main character always writes a little essay in their mind while taking the elevator down before the class trial.

But what if they cannot write anything? Zzz ......

So Saihara started thinking about math problems ......

Problem Description

There are positive integers a,b,ca, b, c satisfying the α\alpha equation: 1a1b=1c\dfrac{1}{a} - \dfrac{1}{b} = \dfrac{1}{c}, and gcd(a,b,c)=1\gcd(a, b, c) = 1.

Given a positive integer NN, write a program to compute the number of α\alpha equations with cNc \leq N, and output one bb that satisfies the following condition:

Among all α\alpha equations with c=Nc = N, choose one with the smallest aa.

Input Format

The first line contains a positive integer TT, the number of queries.

The next TT lines each contain one positive integer, the given NN.

Output Format

Output TT lines. Each line contains a positive integer, the number of α\alpha equations that satisfy the condition. If a solution exists, output a space and then output one valid bb.

It can be proven that when N>1N > 1, such a bb always exists.

2
1
2
0
1 2
2
233
2020
479 54056
5470 8181

Hint

Sample #2 Explanation

In the first query, the corresponding equation is: 1232154056=1233\dfrac{1}{232} - \dfrac{1}{54056} = \dfrac{1}{233}, so the second output is 5405654056.

In the second query, the corresponding equation is: $\dfrac{1}{1620} - \dfrac{1}{8181} = \dfrac{1}{2020}$, so the second output is 81818181.

And in these two α\alpha equations, aa is the smallest among all cases with c=Nc = N.


Constraints

For 10%10\% of the testdata, N100N \leq 100, T10T \leq 10.

For 30%30\% of the testdata, N103N \leq 10^3, T100T \leq 100.

For 70%70\% of the testdata, N105N \leq 10^5, T104T \leq 10^4.

For 100%100\% of the testdata, N2×106N \leq 2 \times 10^6, T105T \leq 10^5.


About Special Judge

This problem uses Special Judge.

If you answer the first question all correctly but make mistakes on the second question, you will get 30%30\% of the score. If you answer the first question incorrectly but answer the second question all correctly, you will get 70%70\% of the score. However, if both the first and the second questions have some or all wrong answers, you will be judged as WA. Also, if your output is incomplete or has extra parts, for example, you only answer the first question but do not output the answer for the second question (except when N=1N = 1), or you output one extra number when N=1N = 1, then you will also get no score.

Translated by ChatGPT 5