fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. ll a[200001],prefix[200001];
  5. vector<ll> adj[100001];
  6. void solve()
  7. {
  8. ll i,j,k,l,m,n,o,p,q,r;
  9. cin>>n;
  10.  
  11. //cout<<adj[10000].size()<<endl;
  12. vector<pair<ll,ll>> vp;
  13. for(i=0;i<n;i++)
  14. {
  15. cin>>a[i];
  16. if(i>=1)
  17. {
  18. ll x,y;
  19. o=-a[i];
  20. p=abs(o);
  21. if(p%n==0)
  22. {
  23. if(o>0)
  24. vp.push_back({-1*p/n,0});
  25. else
  26. vp.push_back({p/n,0});
  27. }
  28. else
  29. {
  30. k=p/n;
  31. k++;
  32. q=k*n;
  33. if(o>0)
  34. {
  35. y=q-o;
  36. x=k-y;
  37. vp.push_back({-1*x,-1*y});
  38. }
  39. else
  40. {
  41. k--;
  42. q=-1*k;
  43. q*=n;
  44. y=o-q;
  45. x=k-y;
  46. vp.push_back({x,y});
  47. }
  48. }
  49. }
  50.  
  51. }
  52. cout<<1<<" "<<n<<endl;
  53. for(i=0;i<n;i++)
  54. {
  55. if(i==0)
  56. {
  57. cout<<n<<" ";
  58. a[0]+=n;
  59. }
  60. else
  61. {
  62. cout<<vp[i-1].first*(-1*n)<<" ";
  63. }
  64. }
  65. cout<<endl;
  66. cout<<2<<" "<<n<<endl;
  67. for(i=0;i<n;i++)
  68. {
  69. if(i==0)
  70. {
  71.  
  72. }
  73. else
  74. {
  75. cout<<vp[i-1].second*(-1*(n-1))<<" ";
  76. }
  77. }
  78. cout<<endl;
  79. cout<<1<<" "<<1<<endl;
  80. cout<<-1*a[0]<<endl;
  81.  
  82. }
  83. int main()
  84. {
  85. ios_base::sync_with_stdio(false);
  86. cin.tie(0);
  87. ll t=1;
  88. //cin>>t;
  89. while(t--)
  90. {
  91. solve();
  92. }
  93. return 0;
  94. }
  95.  
Success #stdin #stdout 0s 5984KB
stdin
5
2 2 4 -3 1
stdout
1 5
5 -10 -20 -5 -5 
2 5
8 16 8 4 
1 1
-7