#P9796. [NERC 2018] Fractions

[NERC 2018] Fractions

Background

Translated from Problem F of NERC 2018.

Problem Description

You are given an integer nn. You need to construct several proper fractions of the form aibi\dfrac{a_i}{b_i} such that i=1kaibi=11n\sum^k_{i=1} \frac{a_i}{b_i} = 1 - \frac{1}{n}, and each bib_i can divide nn.

Input Format

A positive integer nn (2n109)(2 \leq n \leq 10^9).

Output Format

If it is impossible to construct, output one line NO.

Otherwise, output one valid solution. Output YES, and make i=1kaibi=11n\sum^k_{i=1} \frac{a_i}{b_i} = 1 - \frac{1}{n}. On the second line output an integer kk, then in the next kk lines output two integers aia_i and bib_i (bin)(b_i \neq n).

Note that the range of kk you output must satisfy 2k1052 \leq k \leq 10^5.

2
NO
6
YES
2
1 2
1 3

Hint

For all testdata, it is guaranteed that 2n1092 \leq n \leq 10^9.

For the first sample, there is no solution whose sum equals 12\frac{1}{2}.

For the second sample, 12+13=56\frac{1}{2} + \frac{1}{3} = \frac{5}{6}.

Translated by ChatGPT 5