#P6250. 分拆

分拆

Description

Little W defines a kind of “good partition”:

For a positive integer nn, if there exist nn integers (a1,a2,,an)(a_1,a_2,\cdots,a_n) such that i=1nai=i=1nai=n\sum\limits_{i=1}^n a_i=\prod\limits_{i=1}^n a_i=n, then nn is called “good”, and (a1,a2,,an)(a_1,a_2,\cdots,a_n) is a “good partition” of nn.

Now, Little W gives you some nn. He wants you to determine whether each nn is “good”. If it is good, output any “good partition” of nn.

Input Format

The first line contains an integer TT, indicating the number of test cases.

The next TT lines each contain an integer nn, representing one query from Little W.

Output Format

For each test case, output several lines.

If nn is not “good”, output only one line NO.

Otherwise, output YES in the first line. Then output one integer aa in the next line, meaning how many different values appear in your “good partition”. In the next aa lines, output two integers x,yx,y, meaning there are xx occurrences of yy.

3
1
2
5
YES
1
1 1
NO
YES
3
1 5
2 1
2 -1

Hint

Sample Explanation

When n=1n=1, (1)(1) is a “good partition” of 11.

When n=2n=2, 22 has no “good partition”.

When n=5n=5, $5+1+1+(-1)+(-1)=5\times1\times1\times(-1)\times(-1)=5$, so (5,1,1,1,1)(5,1,1,-1,-1) is a “good partition” of 55.

Constraints

This problem is not bundled for judging.
Subtask  1(10  pts)\text{Subtask\;1(10\;pts)}: n=1,T=1000n=1,T=1000;
Subtask  2(30  pts)\text{Subtask\;2(30\;pts)}: n104,T=100n\le 10^4,T=100;
Subtask  3(60  pts)\text{Subtask\;3(60\;pts)}: T=1000T=1000.
For all testdata, 1n1091\le n\le10^9.

Notes

This problem uses SPJ\text{SPJ}.

A test point gets full score if and only if, for all TT test cases in that test point:

  • The answer in the first line is the same.
  • If the answer in the first line is YES, it must also satisfy 1a201\le a\le 20, 1xn1\le x\le n, y×x=yx=x=n\sum y\times x=\prod y^x=\sum x=n.

To make it easier to write the SPJ\text{SPJ}, it is allowed that some yy are the same. Also, please make sure there is one and only one newline at the end of the output file.

For the SPJ\text{SPJ} source code, please see the Cloud Clipboard.

Translated by ChatGPT 5