P6250 Partition

Background

Little W likes partitioning.

Description

Little W defines a kind of “good partition”: For a positive integer $n$, if there exist $n$ integers $(a_1,a_2,\cdots,a_n)$ such that $\sum\limits_{i=1}^n a_i=\prod\limits_{i=1}^n a_i=n$, then $n$ is called “good”, and $(a_1,a_2,\cdots,a_n)$ is a “good partition” of $n$. Now, Little W gives you some $n$. He wants you to determine whether each $n$ is “good”. If it is good, output **any** “good partition” of $n$.

Input Format

The first line contains an integer $T$, indicating the number of test cases. The next $T$ lines each contain an integer $n$, representing one query from Little W.

Output Format

For each test case, output several lines. If $n$ is not “good”, output only one line `NO`. Otherwise, output `YES` in the first line. Then output one integer $a$ in the next line, meaning how many different values appear in your “good partition”. In the next $a$ lines, output two integers $x,y$, meaning there are $x$ occurrences of $y$.

Explanation/Hint

# Sample Explanation When $n=1$, $(1)$ is a “good partition” of $1$. When $n=2$, $2$ has no “good partition”. When $n=5$, $5+1+1+(-1)+(-1)=5\times1\times1\times(-1)\times(-1)=5$, so $(5,1,1,-1,-1)$ is a “good partition” of $5$. ## Constraints **This problem is not bundled for judging.** $\text{Subtask\;1(10\;pts)}$: $n=1,T=1000$; $\text{Subtask\;2(30\;pts)}$: $n\le 10^4,T=100$; $\text{Subtask\;3(60\;pts)}$: $T=1000$. For all testdata, $1\le n\le10^9$. ## Notes This problem uses $\text{SPJ}$. A test point gets full score if and only if, for all $T$ 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 $1\le a\le 20$, $1\le x\le n$, $\sum y\times x=\prod y^x=\sum x=n$. **To make it easier to write the $\text{SPJ}$, it is allowed that some $y$ are the same. Also, please make sure there is one and only one newline at the end of the output file.** For the $\text{SPJ}$ source code, please see the [Cloud Clipboard](https://www.luogu.com.cn/paste/tlhjg36n). Translated by ChatGPT 5