#P15655. [ICPC 2025 Jakarta R] Nihilation

    ID: 15563 远端评测题 1000ms 2048MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2025Special Judge最大公约数 gcd构造ICPC

[ICPC 2025 Jakarta R] Nihilation

题目描述

You are given an array A=[A1,A2,,AN]A = [A_1, A_2, \ldots, A_N] consisting of NN positive integers.

In one operation, you can choose integers mm and kk such that 1k<m1091 \leq k < m \leq 10^9 and set Ai:=(Ai×k)modmA_i := (A_i \times k) \bmod m for 1iN1 \leq i \leq N.

What is the minimum number of operations needed to make all AiA_i equal to 00?

Output any sequence of operations to be done. It can be proven that it is always possible to make all AiA_i equal to 00.

输入格式

Input begins with an integer NN (1N1000001 \le N \le 100\,000). The next line contains NN integers AiA_i (1Ai1091 \le A_i \le 10^9) representing the given array AA.

输出格式

In the first line, output the minimum number qq of operations needed.

In the next qq lines, output two integers mm and kk, representing the operation in the sequence of operations that makes all AiA_i equal to 00.

If there are multiple such sequences, output any one of them.

5
4 1 2 6 3
2
12 6
3 2
2
9 9
1
3 1

提示

Explanation of Sample 1:\textit{Explanation of Sample 1:} The following describes the sequence of operations done in the sample output.

  • $A_i := (A_i \times 6) \bmod 12 \implies A = [0, 6, 0, 0, 6]$
  • $A_i := (A_i \times 2) \bmod 3 \implies A = [0, 0, 0, 0, 0]$

It can be shown that no sequence of operations with length 11 can make all AiA_i equal to 00.