Codeforces Round #666 (Div. 2) C. Multiples of Length

tech2022-07-31  123

Codeforces Round #666 (Div. 2) C. Multiples of Length

题目链接 You are given an array a of n integers.

You want to make all elements of a equal to zero by doing the following operation exactly three times:

Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different). It can be proven that it is always possible to make all elements of a equal to zero.

Input

The first line contains one integer n (1≤n≤100000): the number of elements of the array.

The second line contains n elements of an array a separated by spaces: a1,a2,…,an (−109≤ai≤1e9).

Output

The output should contain six lines representing three operations.

For each operation, print two lines:

The first line contains two integers l, r (1≤l≤r≤n): the bounds of the selected segment. The second line contains r−l+1 integers bl,bl+1,…,br (−1e18≤bi≤1e18): the numbers to add to al,al+1,…,ar, respectively; bi should be divisible by r−l+1.

Example

input

4 1 3 2 4

output

1 1 -1 3 4 4 2 2 4 -3 -6 -6

纯思维构造题,当 n = 1 n=1 n=1 时,答案为:

1 1 0 1 1 0 1 1 −a1

n > 1 n>1 n>1 时,答案为:

1 1 −a1 1 n 0, −n⋅a2, −n⋅a3, …, −n⋅an 2 n (n−1)⋅a2, (n−1)⋅a3, …, (n−1)⋅an

AC代码如下:

#include<bits/stdc++.h> typedef long long ll; using namespace std; const int N=1e5+5; ll n,a[N]; int main() { cin>>n; for(ll i=0;i<n;i++) cin>>a[i]; if(n==1){ printf("1 1\n0\n1 1\n0\n1 1\n%lld",-a[0]); }else{ printf("1 1\n%lld\n1 %lld\n0 ",-a[0],n); for(int i=1;i<n;i++) printf(" %lld",-a[i]*n); printf("\n2 %lld\n%lld",n,a[1]*(n-1)); for(int i=2;i<n;i++) printf(" %lld",a[i]*(n-1)); } }
最新回复(0)