题目链接

题意:

给出你长度为n的数组,让你将其转化成数组的负数即\([a_1,a_2,a_3.....a_n]\)变成\([-a_1,-a_2,-a_3....-a_n]\)
你可以进行两种操作:

  1. \(a_i=a_i+a_j\)
  2. \(a_j=a_j−a_i\)

但是必须满足 i<j

思路:

我们用两个数试一下:

a --------ba+b-------b-------1a+b------- -a-------2b--------a-------1b------- -a-b-------2-a------- -a-b-------1-a------- -b-------2

这样我们就可以推出我们只用两个相邻的数即可将其转换成负的,并且题目中给出n是偶数

void solve()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
scanf("%lld", &a[i]);
}
cout << 3 * n << endl;
for(int i = 1; i <= n; i += 2)
{
cout << "1 " << i << " " << i + 1 << '\n';
cout << "2 " << i << " " << i + 1 << '\n';
cout << "1 " << i << " " << i + 1 << '\n';
cout << "2 " << i << " " << i + 1 << '\n';
cout << "1 " << i << " " << i + 1 << '\n';
cout << "2 " << i << " " << i + 1 << '\n';
}
}