We will use the fact that gcd(i,i+1)=1 for any integer i≥1.
任何一个大于等于1的整数,gcd(i,i+1)=1
因此只需要寻找数组中最小的一个数字res
,将数组替换为 res , res + 1, res + 2, ··· , res + len - 1
代码如下
#include <bits/stdc++.h>
#define int long long
#define N 10010
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int , int> PII ;
#define x first
#define y second
void solve() {
int n;
cin >> n;
int res = INF, pos = 0, x;
for(int i = 1; i <= n; i ++ ) {
cin >> x;
if(x < res) res = x, pos = i;
}
cout << n - 1 << endl;
for(int i = 1; i <= n; i ++ ) {
if(i == pos) continue;
cout << pos << ' ' << i << ' ' << res << ' ' << res + abs(i - pos) << endl;
}
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t -- ) {
solve();
}
return 0;
}