当前位置:   article > 正文

Multiples of Length_vlad was given an array aa of nn positive integers

vlad was given an array aa of nn positive integers. now he wants to build a

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的倍数。然后第一次操作对第一个元素进行操作就好了

  1. #include<iostream>
  2. #include<vector>
  3. #include<queue>
  4. #include<cstring>
  5. #include<cmath>
  6. #include<map>
  7. #include<set>
  8. #include<cstdio>
  9. #include<algorithm>
  10. #define debug(a) cout<<#a<<"="<<a<<endl;
  11. using namespace std;
  12. const int maxn=1e5+100;
  13. typedef long long LL;
  14. LL a[maxn];
  15. int main(void)
  16. {
  17. cin.tie(0);std::ios::sync_with_stdio(false);
  18. LL n;cin>>n;
  19. for(LL i=1;i<=n;i++) cin>>a[i];
  20. cout<<"1 1"<<endl;
  21. cout<<(-a[1])<<endl;
  22. if(n==1)
  23. {
  24. cout<<"1 1"<<endl;
  25. cout<<"0"<<endl;
  26. cout<<"1 1"<<endl;
  27. cout<<"0"<<endl;
  28. return 0;
  29. }
  30. cout<<"2"<<" "<<n<<endl;
  31. for(LL i=2;i<=n;i++) cout<<a[i]*(n-1)<<" ";
  32. cout<<endl;
  33. cout<<"1"<<" "<<n<<endl;
  34. for(LL i=1;i<=n;i++)
  35. {
  36. if(i==1) cout<<"0"<<" ";
  37. else cout<<(-1*a[i]*n)<<" ";
  38. }
  39. cout<<endl;
  40. return 0;
  41. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/745357
推荐阅读
相关标签
  

闽ICP备14008679号