CF1521B.Nastia and a Good Array

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Nastia has received an array of nn positive integers as a gift.

She calls such an array aa good that for all ii ( 2in2 \le i \le n ) takes place gcd(ai1,ai)=1gcd(a_{i - 1}, a_{i}) = 1 , where gcd(u,v)gcd(u, v) denotes the greatest common divisor (GCD) of integers uu and vv .

You can perform the operation: select two different indices i,ji, j ( 1i,jn1 \le i, j \le n , iji \neq j ) and two integers x,yx, y ( 1x,y21091 \le x, y \le 2 \cdot 10^9 ) so that min(ai,aj)=min(x,y)\min{(a_i, a_j)} = \min{(x, y)} . Then change aia_i to xx and aja_j to yy .

The girl asks you to make the array good using at most nn operations.

It can be proven that this is always possible.

输入格式

The first line contains a single integer tt ( 1t100001 \le t \le 10\,000 ) — the number of test cases.

The first line of each test case contains a single integer nn ( 1n1051 \le n \le 10^5 ) — the length of the array.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_{n} ( 1ai1091 \le a_i \le 10^9 ) — the array which Nastia has received as a gift.

It's guaranteed that the sum of nn in one test doesn't exceed 21052 \cdot 10^5 .

输出格式

For each of tt test cases print a single integer kk ( 0kn0 \le k \le n ) — the number of operations. You don't need to minimize this number.

In each of the next kk lines print 44 integers ii , jj , xx , yy ( 1ijn1 \le i \neq j \le n , 1x,y21091 \le x, y \le 2 \cdot 10^9 ) so that min(ai,aj)=min(x,y)\min{(a_i, a_j)} = \min{(x, y)} — in this manner you replace aia_i with xx and aja_j with yy .

If there are multiple answers, print any.

输入输出样例

  • 输入#1

    2
    5
    9 6 3 11 15
    3
    7 5 13

    输出#1

    2
    1 5 11 9
    2 5 7 6
    0

说明/提示

Consider the first test case.

Initially a=[9,6,3,11,15]a = [9, 6, 3, 11, 15] .

In the first operation replace a1a_1 with 1111 and a5a_5 with 99 . It's valid, because min(a1,a5)=min(11,9)=9\min{(a_1, a_5)} = \min{(11, 9)} = 9 .

After this a=[11,6,3,11,9]a = [11, 6, 3, 11, 9] .

In the second operation replace a2a_2 with 77 and a5a_5 with 66 . It's valid, because min(a2,a5)=min(7,6)=6\min{(a_2, a_5)} = \min{(7, 6)} = 6 .

After this a=[11,7,3,11,6]a = [11, 7, 3, 11, 6] — a good array.

In the second test case, the initial array is already good.

首页