Ehab and a 2-operation task

题意翻译

# 题目描述 有一个长度为$n$的序列$a$,你可以在这个序列上做两种操作: + 选择下标 $i(1 \leq i \leq n) $ 和一个整数$x(0 \leq x \leq 10^6)$,然后对每一个下标$j(1 \leq j \leq i)$,把所有的$a_j$换成$a_j+x$,也就是说,给序列中以$i$为最后一个元素的前缀中的每一个元素加上$x$. + 选择一个下标$i,(1 \leq i \leq n) $,一个整数$x(0 \leq x \leq 10^6)$,然后对每一个下标$j(1 \leq j \leq i)$,把$a_j$换成 $a_j \% s$,也就是说,把序列中以$i$为最后一个元素的前缀中的每一个元素对$x$取模. 你能在不超过$n+1$次操作之内把这个序列变成严格递增的吗? # 输入输出格式 ## 输入格式: 第一行有一个整数$n(1\leq n \leq 1000)$,代表$a$中元素的个数. 第二行有n个以空格间隔的整数:$a_1,a_2,...,a_n$,$(0 \leq a_i\leq 10^5)$,是序列$a$中的元素. ## 输出格式: 第一行输出你要进行的操作个数. 接下来的每一行,你需要依次输出每一个操作. 要输出添加操作的时候,用"1 i x"(没有引号)的格式;要输出取模操作时,用"2 i x"(没有引号)的格式. 如果$i$或者$x$没有满足题目中的限制,或者你用了超过$n+1$次操作,你的提交就会被认为是错误的。

题目描述

You're given an array $ a $ of length $ n $ . You can perform the following operations on it: - choose an index $ i $ $ (1 \le i \le n) $ , an integer $ x $ $ (0 \le x \le 10^6) $ , and replace $ a_j $ with $ a_j+x $ for all $ (1 \le j \le i) $ , which means add $ x $ to all the elements in the prefix ending at $ i $ . - choose an index $ i $ $ (1 \le i \le n) $ , an integer $ x $ $ (1 \le x \le 10^6) $ , and replace $ a_j $ with $ a_j \% x $ for all $ (1 \le j \le i) $ , which means replace every element in the prefix ending at $ i $ with the remainder after dividing it by $ x $ . Can you make the array strictly increasing in no more than $ n+1 $ operations?

输入输出格式

输入格式


The first line contains an integer $ n $ $ (1 \le n \le 2000) $ , the number of elements in the array $ a $ . The second line contains $ n $ space-separated integers $ a_1 $ , $ a_2 $ , $ \dots $ , $ a_n $ $ (0 \le a_i \le 10^5) $ , the elements of the array $ a $ .

输出格式


On the first line, print the number of operations you wish to perform. On the next lines, you should print the operations. To print an adding operation, use the format " $ 1 $ $ i $ $ x $ "; to print a modding operation, use the format " $ 2 $ $ i $ $ x $ ". If $ i $ or $ x $ don't satisfy the limitations above, or you use more than $ n+1 $ operations, you'll get wrong answer verdict.

输入输出样例

输入样例 #1

3
1 2 3

输出样例 #1

0

输入样例 #2

3
7 6 3

输出样例 #2

2
1 1 1
2 2 4

说明

In the first sample, the array is already increasing so we don't need any operations. In the second sample: In the first step: the array becomes $ [8,6,3] $ . In the second step: the array becomes $ [0,2,3] $ .