CF1762B.Make Array Good
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An array b of m positive integers is good if for all pairs i and j ( 1≤i,j≤m ), max(bi,bj) is divisible by min(bi,bj) .
You are given an array a of n positive integers. You can perform the following operation:
- Select an index i ( 1≤i≤n ) and an integer x ( 0≤x≤ai ) and add x to ai , in other words, ai:=ai+x .
- After this operation, ai≤1018 should be satisfied.
You have to construct a sequence of at most n operations that will make a good. It can be proven that under the constraints of the problem, such a sequence of operations always exists.
输入格式
Each test contains multiple test cases. The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤105 ) — the length of the array a .
The second line of each test case contains n space-separated integers a1,a2,…,an ( 1≤ai≤109 ) — representing the array a .
It is guaranteed that the sum of n over all test cases does not exceed 105 .
输出格式
For each test, output a single integer p ( 0≤p≤n ) — denoting the number of operations in your solution.
In each of the following p lines, output two space-separated integers — i and x .
You do not need to minimize the number of operations. It can be proven that a solution always exists.
输入输出样例
输入#1
4 4 2 3 5 5 2 4 8 5 3 4 343 5 6 3 31 5 17
输出#1
4 1 2 1 1 2 2 3 0 0 5 1 3 1 4 2 1 5 4 3 7 3 1 29 2 5 3 3
说明/提示
In the first test case, array a becomes [5,5,5,5] after the operations. It is easy to see that [5,5,5,5] is good.
In the second test case, array a is already good.
In the third test case, after performing the operations, array a becomes [10,5,350,5,10] , which is good.
In the fourth test case, after performing the operations, array a becomes [60,10,20] , which is good.