Ehab and a 2-operation task
题目链接:http://codeforces.com/problemset/problem/1088/C
涉及知识点:
- 思维/构造
solution:
- 题目要求至多进行n+1次操作
- 构造方法如下:
- 首先让每个数都加上1e5+10,为接下来的取模做准备
- 接下来,我们依次取前1数,前2数....前n个数,取模a[i] + 1e5 + 10 - i
- 这样我们就可以构造出来一个从0开始上升的子序列
std:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 100010;
int a[maxn];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
cout<<n+1<<endl;
cout<<"1 "<<n<<" "<<maxn<<endl;
for(int i=1;i<=n;i++){
cout<<"2 "<<i<<" "<<a[i]+maxn-i<<endl;
}
return 0;
}