zoukankan      html  css  js  c++  java
  • Ehab and a 2-operation task (思维题)

    You're given an array aa of length nn. You can perform the following operations on it:

    • choose an index ii (1≤i≤n)(1≤i≤n), an integer xx (0≤x≤106)(0≤x≤106), and replace ajaj with aj+xaj+x for all (1≤j≤i)(1≤j≤i), which means add xx to all the elements in the prefix ending at ii.
    • choose an index ii (1≤i≤n)(1≤i≤n), an integer xx (1≤x≤106)(1≤x≤106), and replace ajaj with aj%xaj%x for all (1≤j≤i)(1≤j≤i), which means replace every element in the prefix ending at ii with the remainder after dividing it by xx.

    Can you make the array strictly increasing in no more than n+1n+1 operations?

    Input

    The first line contains an integer nn (1≤n≤2000)(1≤n≤2000), the number of elements in the array aa.

    The second line contains nn space-separated integers a1a1, a2a2, ……, anan (0≤ai≤105)(0≤ai≤105), the elements of the array aa.

    Output

    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 "11 ii xx"; to print a modding operation, use the format "22 ii xx". If ii or xx don't satisfy the limitations above, or you use more than n+1n+1 operations, you'll get wrong answer verdict.

    Examples

    Input

    3
    1 2 3
    

    Output

    0

    Input

    3
    7 6 3
    

    Output

    2
    1 1 1
    2 2 4
    

    Note

    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][8,6,3].

    In the second step: the array becomes [0,2,3][0,2,3].

    #include<cstdio>
    #include<cmath>
    #include<iostream>
    #include<queue>
    using namespace std;
    int main(){
    	
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            int x;
            scanf("%d",&x);
        }
        cout<<n+1<<endl;
        printf("2 %d 1
    ",n);
        printf("1 %d 1000000
    ",n);
        for(int i=0;i<n-1;i++){
            printf("2 %d %d
    ",i+1,1000000-i);
        }
        return 0;
    }
  • 相关阅读:
    求长度的另一种方法(""+obj).Length
    XCode中如何使用事务
    最终版 Reflector v1.0 (+简单的反流程混淆)
    与ObjectDataSource共舞
    性能&分布式&NewLife.XCode对无限数据的支持
    XCode之第一次亲密接触
    5,ORM组件XCode(动手)
    你知道吗?多个类多线程环境下静态构造函数的执行顺序
    使用C#编写IDA插件 IDACSharp v1.0.2010.0605
    XCMS V1.0 Beta1 发布
  • 原文地址:https://www.cnblogs.com/Romantic-Chopin/p/12451217.html
Copyright © 2011-2022 走看看