Multiples of Length

https://codeforces.com/contest/1397/problem/C

You are given an array aa of nn integers.

You want to make all elements of aa 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 lenlen to it, where lenlen 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 aa equal to zero.

Input

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

The second line contains nn elements of an array aa separated by spaces: a1,a2,…,ana1,a2,…,an (−109≤ai≤109−109≤ai≤109).

Output

The output should contain six lines representing three operations.

For each operation, print two lines:

 

  • The first line contains two integers ll, rr (1≤l≤r≤n1≤l≤r≤n): the bounds of the selected segment.

     

  • The second line contains r−l+1r−l+1 integers bl,bl+1,…,brbl,bl+1,…,br (−1018≤bi≤1018−1018≤bi≤1018): the numbers to add to al,al+1,…,aral,al+1,…,ar, respectively; bibi should be divisible by r−l+1r−l+1.

Example

input

Copy

4
1 3 2 4

output

Copy

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

 

思路:由于题目说只进行三次操作,容易思考到前两次变到n的倍数,最后一次整个变成0.考虑到区间尽可能长且开始进行长度为n的操作无法满足,考虑长度为n-1,可以发现a[i]+a[i]*(n-1)刚好可以变成n的倍数。然后第一次操作对第一个元素进行操作就好了

#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
LL a[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL n;cin>>n;
  for(LL i=1;i<=n;i++) cin>>a[i];
  cout<<"1 1"<<endl;
  cout<<(-a[1])<<endl;
  if(n==1)
  {
  	cout<<"1 1"<<endl;
	cout<<"0"<<endl;
	cout<<"1 1"<<endl;
	cout<<"0"<<endl;
	return 0;
  }
  cout<<"2"<<" "<<n<<endl;
  for(LL i=2;i<=n;i++) cout<<a[i]*(n-1)<<" ";
  cout<<endl;
  cout<<"1"<<" "<<n<<endl;
  for(LL i=1;i<=n;i++)
  {
  	if(i==1) cout<<"0"<<" ";
  	else cout<<(-1*a[i]*n)<<" ";
  }
  cout<<endl;
return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值