text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
const long long mxn = 100010;
void solve(long long tc) {
long long n;
cin >> n;
long long two = 0, three = 0;
while (n % 2 == 0) two++, n /= 2;
while (n % 3 == 0) three++, n /= 3;
if (n != 1)
cout << -1 << '\n';
else {
if (two <= three) {
cout << three - two + three << '\n';
} else {
cout << -1 << '\n';
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long tc;
cin >> tc;
for (long long t = (1), ed = (tc + 1); t < (ed); ++t) solve(t);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
int m = 0;
while (n % 6 == 0) n /= 6, m++;
while (n % 3 == 0) n /= 3, m += 2;
if (n == 1)
cout << m << endl;
else
cout << "-1" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
int nb = 0;
int i = 0;
while (n != 1) {
if (n % 6 == 0) {
n /= 6;
i++;
} else if (n * 2 % 6 != 0) {
i = -1;
break;
} else {
n *= 2;
i++;
}
}
cout << i << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t;
int primeFact(long long n) {
int two = 0, three = 0;
while (n > 1) {
if (n % 2 == 0) {
n /= 2;
two++;
} else if (n % 3 == 0) {
n /= 3;
three++;
} else {
return -1;
}
}
if (two > three) return -1;
return three - two + three;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
while (t--) {
long long n;
cin >> n;
int ans = primeFact(n);
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, i = 0;
cin >> n;
while (n >= 6 && n % 6 == 0) {
n = n / 6;
i++;
}
while (n >= 3 && n % 3 == 0) {
n = n / 3;
i += 2;
}
if (n > 1)
cout << "-1" << endl;
else
cout << i << endl;
}
}
|
#include <bits/stdc++.h>
int main() {
int t, n, s, count = 0;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
if (n == 1) {
printf("0\n");
} else if (n == 2) {
printf("-1\n");
} else if ((n * 2) % 6 != 0) {
printf("-1\n");
} else {
while (n > 1) {
if (n % 6 == 0) {
n = n / 6;
count++;
} else {
n = n * 2;
count++;
}
}
if (n == 1) {
printf("%d\n", count);
} else {
printf("-1\n");
}
count = 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int to = 0, thr = 0;
while (n % 2 == 0) {
to++;
n = n / 2;
}
while (n % 3 == 0) {
thr++;
n = n / 3;
}
if (n > 1) {
cout << "-1";
cout << "\n";
} else {
if (to > thr) {
cout << "-1";
cout << "\n";
} else {
cout << 2 * thr - to;
cout << "\n";
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
if (n == 1) {
cout << "0\n";
return;
}
if (n < 6 && n != 3) {
cout << "-1\n";
return;
}
int count = 0;
while (n % 3 == 0) {
while (n % 6 == 0) {
n /= 6;
count++;
}
if (n % 3 == 0) {
n *= 2;
count++;
} else if (n != 1) {
cout << "-1"
<< "\n";
return;
} else {
if (n == 1) break;
}
}
if (n != 1) {
cout << "-1\n";
return;
}
cout << count << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void init() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
init();
int t;
cin >> t;
for (int _ = 0; _ < t; _++) {
int n;
cin >> n;
int a = 0, b = 0;
while (n % 2 == 0) {
n /= 2;
a++;
}
while (n % 3 == 0) {
n /= 3;
b++;
}
if (a > b || n != 1) {
cout << "-1\n";
} else {
cout << (b + (b - a)) << '\n';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, c1 = 0, c2 = 0;
cin >> n;
while (n > 0) {
if (n % 2 == 0)
n = n / 2;
else
break;
c1++;
}
while (n > 0) {
if (n % 3 == 0)
n = n / 3;
else
break;
c2++;
}
if (n != 1 || c1 > c2)
cout << "-1" << endl;
else
cout << c2 - c1 + c2 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Log3n(long long n) { return (n > 1) ? 1 + Log3n(n / 3) : 0; }
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long t;
cin >> t;
while (t--) {
long long n, c, count = 0, d = 0, b;
cin >> n;
if (n == 1) {
cout << "0" << '\n';
continue;
}
while (n % 6 == 0) {
n = n / 6;
count++;
}
if (n != 1) {
c = Log3n(n);
b = pow(3, c);
if (n == b)
count = count + 2 * c;
else
d = 1;
}
if (d == 1)
cout << "-1" << '\n';
else
cout << count << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int cnt2 = 0, cnt3 = 0;
while (n % 2 == 0) {
n /= 2;
++cnt2;
}
while (n % 3 == 0) {
n /= 3;
++cnt3;
}
if (n == 1 && cnt2 <= cnt3) {
cout << 2 * cnt3 - cnt2 << endl;
} else {
cout << -1 << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Number>
Number gcd(Number u, Number v) {
while (v != 0) {
Number r = u % v;
u = v;
v = r;
}
return u;
}
long long int binSearch(vector<long long int> v, long long int l,
long long int r, long long int x) {
if (r >= l) {
long long int mid = l + (r - l) / 2;
if (v[mid] == x) return mid;
if (v[mid] > x) return binSearch(v, l, mid - 1, x);
return binSearch(v, mid + 1, r, x);
}
return -1;
}
void solve() {
long long int n;
cin >> n;
long long int temp = n;
long long int po2 = 0, po3 = 0;
while (n % 2 == 0 || n % 3 == 0) {
if (n % 2 == 0) {
po2++;
n /= 2;
}
if (n % 3 == 0) {
po3++;
n /= 3;
}
}
if (n != 1) {
cout << -1 << endl;
return;
}
if (po2 > po3) {
cout << -1 << endl;
return;
}
long long int ans = 0;
ans = (po3 - po2) + po3;
cout << ans << endl;
return;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long long int> v(500001, 0);
struct node {
int a, b;
};
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int two = 0, three = 0;
bool flag = true;
void factorize(long long n) {
long long int count = 0;
while (!(n % 2)) {
two++;
n >>= 1;
}
for (long long i = 3; i <= sqrt(n); i += 2) {
while (n % i == 0) {
if (i == 3)
three++;
else {
flag = false;
return;
}
n = n / i;
}
}
if (n > 2) {
if (n != 3) {
flag = false;
return;
}
three++;
}
}
void test(int r) {
flag = true;
two = 0, three = 0;
long long int n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
} else {
while (n % 2 == 0 || n % 3 == 0) {
if (n % 2 == 0) {
n /= 2;
two++;
} else {
n /= 3;
three++;
}
}
if (n != 1 || two > three)
cout << -1 << endl;
else {
long long int a = three - two;
long long int count = three + a;
cout << count << endl;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1, r;
cin >> t;
for (r = 1; r <= t; r++) test(r);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n, c = 0;
cin >> t;
while (t--) {
c = 0;
cin >> n;
while (n != 1) {
if (n % 3 != 0) {
c = -1;
break;
} else if (n % 6 == 0) {
n = n / 6;
c++;
} else {
n = n * 2;
c++;
}
}
cout << c << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y);
long long int mpower(long long int x, long long int y, long long int p);
long long int modInv(long long int a, long long int m);
long long int gcdExtended(long long int a, long long int b, long long int *x,
long long int *y);
bool isPrime(long long int n);
long long int lvl[1000][1000];
bool A[1000][1000];
long long int modInv(long long int a, long long int m) {
long long int x, y;
long long int g = gcdExtended(a, m, &x, &y);
long long int res = (x % m + m) % m;
return res;
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
long long int *y) {
if (a == 0) {
*x = 0, *y = 1;
return b;
}
long long int x1, y1;
long long int gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
long long int gcd(long long int x, long long int y) {
return (x == 0) ? y : gcd(y % x, x);
}
long long int mpower(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
bool sortbysec(const pair<long long int, long long int> &a,
const pair<long long int, long long int> &b) {
return (a.second < b.second);
}
void addEdge(vector<long long int> adj[], long long int u, long long int v) {
adj[u].push_back(v);
adj[v].push_back(u);
}
void DFSE(vector<long long int> adj[], vector<bool> &visited, long long int u) {
long long int i;
visited[u] = true;
cout << u << " ";
for (long long int i = 0; i < adj[u].size(); i++) {
if (visited[adj[u][i]] == false) {
DFSE(adj, visited, adj[u][i]);
}
}
}
void DFS(vector<long long int> adj[], long long int u, long long int v) {
long long int i;
vector<bool> visited(v, false);
for (long long int i = 0; i < v; i++) {
if (visited[i] == false) {
DFSE(adj, visited, i);
}
}
}
long long int power(long long int x, long long int y) {
long long int res = 1;
while (y > 0) {
if (y & 1) res = res * x;
y = y >> 1;
x = x * x;
}
return res;
}
bool isPrime(long long int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
long long int p = sqrt(n);
for (int i = 5; i <= p; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
long long int pow(long long int base, long long int expo, long long int m) {
if (m == 1) return 0;
long long int ans = 1, y = base % m;
while (expo > 0) {
if (expo & 1) ans = ((ans)*y) % m;
y = (y * y) % m;
if (y < 0) y += m;
expo = expo >> 1;
}
if (ans < 0) {
ans = (m - abs(ans) % m);
return ans;
}
return ans % m;
}
vector<long long int> Divisors(long long int n) {
vector<long long int> vec;
vec.clear();
for (long long int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (n / i == i)
vec.push_back(i);
else {
vec.push_back(i);
vec.push_back(n / i);
}
}
}
return vec;
}
long long int two(long long int n) {
long long int c = 0;
while (n % 2 == 0) {
c++;
n /= 2;
}
return c;
}
long long int three(long long int n) {
long long int c = 0;
while (n % 3 == 0) {
c++;
n /= 3;
}
return c;
}
void slv() {
long long int t, n, m, q, p, r, c, d, x, y, k, z, h, o, e, l, u, i, j, a, b;
string s, s1, s2;
cin >> n;
b = two(n);
c = three(n);
if (n == 1)
cout << 0 << '\n';
else if (c == 0 && n != 1)
cout << -1 << '\n';
else if (b > c)
cout << -1 << '\n';
else if (pow(2, b) * pow(3, c) != n)
cout << -1 << '\n';
else
cout << b + 2 * (c - b) << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t, n, m, k, q, p, r, a, b, c, d, x, y, z, h, o, e, l, u, i, j;
t = 1;
cin >> t;
while (t--) {
slv();
}
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long long> g[100007];
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long a = 0;
long long b = 0;
while (n % 3 == 0) {
a++;
n /= 3;
}
while (n % 2 == 0) {
n /= 2;
b++;
}
if (n != 1 || (a - b) < 0) {
cout << -1 << '\n';
} else {
cout << 2 * a - b << '\n';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for (int tt = 0; tt < t; tt++) {
long long n;
cin >> n;
long long steps = 0;
bool not_pos = false;
if (n == 1) {
cout << steps << endl;
} else {
while (n > 1) {
if (n % 3 != 0) {
not_pos = true;
break;
} else {
if (n % 6 == 0) {
n /= 6;
steps++;
} else {
n *= 2;
steps++;
}
}
}
if (not_pos)
cout << -1 << endl;
else {
cout << steps << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n, s = 0, c = 0, x = 0;
cin >> n;
x = x + n;
int m;
while (n != 1) {
if (n % 6 == 0) {
n = n / 6;
s++;
} else {
n = n * 2;
c++;
}
if (n > x * 2) {
m = 1;
break;
}
}
if (m == 1) {
cout << -1 << endl;
} else {
cout << s + c << endl;
}
m = 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
int ans = 0;
while (n % 6 == 0 || (2 * n) % 6 == 0) {
if (n % 6 == 0) {
n /= 6;
ans++;
} else {
n /= 3;
ans += 2;
}
}
if (n == 1)
cout << ans << endl;
else
cout << "-1\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<int> vec;
int t;
cin >> t;
while (t--) {
int cnt = 0;
long long n;
cin >> n;
while (n > 1) {
if (n % 6 == 0)
n = n / 6;
else
n = n * 2;
cnt++;
}
if (n == 1)
cout << cnt << '\n';
else
cout << -1 << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
int a = 0;
int b = 0;
while (n != 1) {
if (n % 2 == 0) {
n = n / 2;
a++;
} else {
break;
}
}
while (n != 1) {
if (n % 3 == 0) {
n = n / 3;
b++;
} else {
break;
}
}
if (n == 1 && a <= b) {
cout << 2 * b - a << endl;
} else {
cout << -1 << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long n;
cin >> n;
long count1 = 0, count2 = 0;
int f = 0;
while (n != 1) {
if (n % 3 == 0) {
n = n / 3;
count1++;
}
if (n % 2 == 0) {
n = n / 2;
count2++;
}
if (n % 3 != 0 and n % 2 != 0 and n != 1) {
f = 1;
break;
}
}
if (f == 1)
cout << "-1" << endl;
else if (count1 >= count2 and f == 0) {
long ans = count1 - count2;
if (count1 - count2 != 0)
ans += count1;
else
ans = count1;
cout << ans << endl;
} else
cout << "-1" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll MAXN = 1e7 + 10;
int spf[MAXN];
void sieveof() {
spf[1] = 1;
for (int i = 2; i < MAXN; i++) {
spf[i] = i;
}
for (int i = 4; i < MAXN; i += 2) {
spf[i] = 2;
}
for (int i = 3; i * i < MAXN; i++) {
if (spf[i] == i) {
for (int j = i * i; j < MAXN; j += i) {
if (spf[j] == j) {
spf[j] = i;
}
}
}
}
}
ll MSum(vector<ll> arr, ll n, ll k) {
ll sum = 0;
ll cnt = 0, maxcnt = 0;
for (int i = 0; i < n; i++) {
if ((sum + arr[i]) <= k) {
sum += arr[i];
cnt++;
} else if (sum != 0) {
sum = sum - arr[i - cnt] + arr[i];
}
maxcnt = max(cnt, maxcnt);
}
return maxcnt;
}
void solve() {
ll x, y, n, ans = 0, flag = 1;
cin >> n;
while (n > 1) {
if (n % 6 == 0) {
n /= 6;
} else {
n *= 2;
}
ans++;
}
n == 1 ? cout << ans << "\n" : cout << "-1\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double asd;
long long i, l, r, o, t, c, p, w, k, m, h, n, f1, f2, f3, j, a1[1001], xx, y11,
y22, ans, ans1, ans2, mn, mx, sum1, sum, x, y, kol, kol1, kol2[1001], kl1,
kl2, kl11, kl22;
string s, s1;
long long a, b;
int main() {
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n;
while (n > 1) {
if (n % 6 == 0)
n /= 6;
else
n *= 2;
kol++;
if (n < 1) {
break;
}
}
if (n == 1)
cout << kol << endl;
else
cout << "-1" << endl;
kol = 0;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
bool f = 1;
cin >> t;
while (t--) {
int n, c = 0;
cin >> n;
if (n == 1) {
cout << 0 << "\n";
f = 0;
}
while (n != 1) {
if (n % 6 == 0) {
n = n / 6;
c++;
f = 1;
} else if (n % 3 == 0) {
n = n * 2;
c++;
f = 1;
} else {
cout << -1 << "\n";
f = 0;
n = 1;
}
}
if (f) cout << c << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, min;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
for (min = 0; n % 3 == 0 && n > 1; min++) {
if (n % 6 == 0)
n /= 6;
else
n *= 2;
}
if (n == 1)
cout << min << endl;
else
cout << -1 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using namespace std;
const int BUBEN = 550;
const int MOD = 1e9 + 7;
const int BASE = 29;
const int MOD1 = 998244353;
const int BASE1 = 31;
char _getchar_nolock() { return getchar_unlocked(); }
char _putchar_nolock(char i) { return putchar_unlocked(i); }
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<long long> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
if (n == 1) {
cout << "1 1\n" << -arr[0] << "\n1 1\n0\n1 1\n0";
} else {
cout << "1 " << n - 1 << '\n';
for (int i = 0; i + 1 < n; i++) {
cout << (n - 1) * (arr[i] % n) << ' ';
arr[i] += (n - 1) * (arr[i] % n);
}
cout << '\n' << n << ' ' << n << '\n';
cout << n - (arr[n - 1] % n) << '\n';
arr[n - 1] += n - (arr[n - 1] % n);
cout << 1 << ' ' << n << '\n';
for (int i = 0; i < n; i++) {
cout << -arr[i] << ' ';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int N;
int arr[101010];
int main() {
cin >> N;
for (int i = 0; i < N; ++i) cin >> arr[i];
if (N == 1) {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << -arr[0] << endl;
} else {
cout << 1 << " " << N << endl;
for (int i = 0; i < N; ++i) cout << -1LL * arr[i] * N << " ";
cout << endl;
cout << 1 << " " << N - 1 << endl;
for (int i = 0; i < N - 1; ++i) cout << 1LL * arr[i] * (N - 1) << " ";
cout << endl;
cout << N << " " << N << endl;
cout << 1LL * arr[N - 1] * (N - 1) << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long maxs = 1e5 + 3;
const long long maxs1 = 1e3 + 4;
const long long mod = 1e9 + 7;
inline long long add(long long a, long long b) { return (mod + a + b) % mod; }
inline long long sub(long long a, long long b) { return (a - b + mod) % mod; }
inline long long mul(long long a, long long b) { return (1ll * a * b) % mod; }
long long fastpow(long long x, long long y) {
long long res = 1;
x = x % mod;
while (y > 0) {
if (y & 1) res = (res * x) % mod;
y = y >> 1;
x = (x * x) % mod;
}
return res;
}
long long inv(long long x) { return fastpow(x, mod - 2); }
bool isPrime(long long n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
long long arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -arr[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return 0;
}
cout << 1 << " " << 1 << endl;
cout << (n - 1) * arr[0] << endl;
cout << 2 << " " << n << endl;
for (int i = 1; i < n; i++) {
cout << (n - 1) * arr[i] << " ";
}
cout << endl;
cout << 1 << " " << n << endl;
for (int i = 0; i < n; i++) {
cout << -(n)*arr[i] << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
vector<long long> a(n);
for (long long &i : a) cin >> i;
cout << "1 1\n" << -a[0] << '\n';
a[0] = 0;
if (n == 1) {
cout << "1 1\n0\n1 1\n0\n";
return 0;
}
cout << "2 " << n << '\n';
for (int i = 1; i < n; i++) {
long long d = a[i] % n;
if (d < 0) d += n;
cout << (n - 1) * d << " ";
a[i] += (n - 1) * d;
}
cout << '\n';
cout << "1 " << n << '\n';
for (int i = 0; i < n; i++) {
cout << -a[i] << " ";
}
cout << '\n';
}
|
#include <bits/stdc++.h>
const double PI = acos(-1);
long long A[100001];
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> A[i];
}
if (n == 1) {
cout << 1 << ' ' << 1 << '\n';
cout << 100000000000 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << -(A[1] + 100000000000) << '\n';
} else {
cout << 1 << ' ' << n << '\n';
for (int i = 1; i < n; i++) {
cout << -A[i] * n << ' ';
}
long long k = 10000000000000 / n;
cout << n * k;
cout << '\n' << 1 << ' ' << n - 1 << '\n';
for (int i = 1; i <= n - 1; i++) cout << A[i] * (n - 1) << ' ';
cout << '\n' << n << ' ' << n << '\n';
cout << -(A[n] + n * k);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
a[1] = 0;
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
exit(0);
}
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
a[1] = 0;
cout << 2 << " " << n << '\n';
for (int i = 2; i <= n; i++) {
int tg = a[i] % n;
long long kq = 1ll * tg * (n - 1);
cout << kq << " ";
a[i] += kq;
}
cout << '\n';
cout << 1 << " " << n << '\n';
for (int i = 1; i <= n; i++) cout << -a[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[100009];
int n;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
if (n > 1) {
cout << 1 << ' ' << n - 1 << endl;
for (int i = 1; i <= n - 1; i++)
if (a[i] == 0)
cout << (long long)(n - 1) * n << ' ';
else
cout << a[i] * (n - 1) << ' ';
cout << endl;
cout << 1 << ' ' << n << endl;
for (int i = 1; i <= n; i++)
if (a[i] == 0)
cout << -(long long)(n - 1) * n << ' ';
else
cout << -a[i] * n << ' ';
cout << endl;
cout << n << ' ' << n << endl;
if (a[n] == 0)
cout << (long long)(n - 1) * n;
else
cout << a[n] * (n - 1) << endl;
} else
cout << "1 1" << endl
<< 1 << endl
<< "1 1" << endl
<< 1 << endl
<< "1 1" << endl
<< -a[1] - 2;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t, n, i, m;
cin >> n;
long long a[n + 1];
for (i = 0; i < n; i++) cin >> a[i];
if (n > 1) {
cout << 2 << " " << n << endl;
for (i = 1; i < n; i++) {
cout << a[i] * (n - 1) << " ";
a[i] = a[i] * n;
}
cout << endl;
cout << 1 << " " << n << endl;
for (i = 0; i < n; i++) {
if (i)
cout << (-a[i]) << " ";
else
cout << 0 << " ";
}
cout << endl;
}
cout << 1 << " " << 1 << endl;
cout << (-a[0]) << endl;
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long power(long long base, long long exp);
void solve() {
long long n;
cin >> n;
vector<long long> arr(n, 0);
for (long long i = 0; i < n; i++) cin >> arr[i];
if (n == 1) {
long long i = 3;
while (i--) {
cout << 1 << " " << 1 << "\n";
if (i != 0)
cout << 0 << "\n";
else
cout << -arr[0] << "\n";
}
} else {
cout << 1 << " " << 1 << "\n";
cout << -arr[0] << "\n";
arr[0] = 0;
cout << 1 << " " << n << "\n";
for (long long i = 0; i < n; i++) {
cout << -n * arr[i] << " ";
}
cout << "\n";
cout << 2 << " " << n << "\n";
for (long long i = 1; i < n; i++) {
cout << (n - 1) * arr[i] << " ";
}
cout << "\n";
}
}
int32_t main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
long long t = 1;
while (t--) {
solve();
}
return 0;
}
long long power(long long base, long long exp) {
base %= 1000000007;
long long result = 1;
while (exp > 0) {
if (exp & 1) result = ((long long)result * base) % 1000000007;
base = ((long long)base * base) % 1000000007;
exp >>= 1;
}
return result;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
const long long MAX = INT_MAX;
const long long MOD = 1e9 + 7;
const long long sz = 1e5 + 5;
long long gcd(long long a, long long b, long long& x, long long& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long x1, y1;
long long d = gcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
bool find_any_solution(long long a, long long b, long long c, long long& x0,
long long& y0) {
long long g = gcd(abs(a), abs(b), x0, y0);
if (c % g) {
return false;
}
x0 *= c / g;
y0 *= c / g;
if (a < 0) x0 = -x0;
if (b < 0) y0 = -y0;
return true;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long tc = 1;
while (tc--) {
long long n;
cin >> n;
vector<long long> v(n + 1);
for (long long i = 1; i < n + 1; ++i) cin >> v[i];
if (n <= 3) {
for (long long i = 1; i < n + 1; ++i) {
cout << i << " " << i << "\n";
cout << -v[i] << "\n";
}
if (n == 1) {
cout << "1 1"
<< "\n";
cout << "0"
<< "\n";
cout << "1 1"
<< "\n";
cout << "0"
<< "\n";
}
if (n == 2) {
cout << "1 2"
<< "\n";
cout << "0 0"
<< "\n";
}
return 0;
}
cout << "1 1"
<< "\n";
cout << -v[1] << "\n";
cout << "2 " << n << "\n";
vector<long long> other;
for (long long i = 2; i < n + 1; ++i) {
long long x1, x2;
find_any_solution(n - 1, n, -v[i], x1, x2);
cout << (n - 1) * x1 << " ";
other.push_back(x2 * n);
}
cout << "\n";
cout << "1 " << n << "\n";
cout << "0 ";
for (auto el : other) cout << el << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
t = 1;
while (t--) {
long long n;
cin >> n;
vector<long long> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
if (n == 1) {
cout << "1 1\n";
cout << 0 << "\n";
cout << "1 1\n";
cout << 0 << "\n";
cout << "1 1\n";
cout << (-v[0]) << "\n";
} else {
cout << 1 << " " << n << "\n";
for (int i = 0; i < n; i++) cout << (-v[i] * n) << " ";
cout << "\n";
cout << "1 " << n - 1 << "\n";
for (int i = 0; i + 1 < n; i++) cout << v[i] * (n - 1) << " ";
cout << "\n";
cout << 2 << " " << n << "\n";
for (int i = 1; i + 1 < n; i++) cout << "0 ";
cout << (v[n - 1] * (n - 1)) << " ";
cout << "\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
long long n;
cin >> n;
vector<long long> v(n);
for (long long i = 0; i <= n - 1; i++) cin >> v[i];
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << -v[0] << '\n';
cout << 1 << " " << 1 << '\n';
cout << v[0] << '\n';
cout << 1 << " " << 1 << '\n';
cout << -v[0] << '\n';
return;
}
vector<long long> temp;
for (long long i = 0; i <= n - 1; i++) {
long long zz = (v[i] % (n - 1));
temp.push_back(((n - 1) - zz) * n);
}
cout << 1 << " " << n << '\n';
for (auto it : temp) cout << it << " ";
cout << '\n';
cout << 1 << " " << 1 << '\n';
cout << -(v[0] + temp[0]) << '\n';
cout << 2 << " " << n << '\n';
for (long long i = 1; i <= n - 1; i++) {
cout << -(v[i] + temp[i]) << " ";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS = 1;
while (TESTS--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 1001001001;
const int MAX = 1e5 + 5;
int main() {
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<ll> m(n, 0);
ll cnt = n - 1;
for (ll i = 0; i < n; i++) {
if (m[cnt] != 0) break;
m[cnt] = i + 1;
cnt += n - 1;
if (cnt >= n) cnt -= n;
}
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
a[0] = 0;
if (n > 1) {
cout << 2 << " " << n << endl;
for (int i = 1; i < n; i++) {
ll tmp = (n - a[i] % n) % n;
cout << m[tmp] * (n - 1) << " ";
a[i] += m[tmp] * (n - 1);
}
cout << '\n';
} else {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
}
cout << 1 << " " << n << endl;
for (int i = 0; i < n; i++) {
cout << -a[i] << " ";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long int> a(n, 0);
for (int i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
for (int i = 0; i < 2; i++) {
cout << 1 << ' ' << 1 << endl;
cout << 0 << endl;
}
cout << 1 << ' ' << 1 << endl;
cout << -a[0] << endl;
return 0;
}
cout << 1 << ' ' << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
long long int mod = a[i] % (n);
if (mod < 0) mod += n;
if ((n - 1) * mod <= (long long int)(1e18)) {
cout << (n - 1) * mod << ' ';
a[i] = (n - 1) * mod + a[i];
} else if ((n - 1) * (mod - n) >= (long long int)(-1e18)) {
cout << (n - 1) * (mod - n) << ' ';
a[i] = (n - 1) * (mod - n) + a[i];
}
}
cout << endl;
cout << 2 << ' ' << n << endl;
for (int i = 1; i < n; i++) {
long long int mod = a[i] % (n);
if (mod < 0) mod += n;
if ((n - 1) * mod <= (long long int)(1e18)) {
cout << (n - 1) * mod << ' ';
a[i] = (n - 1) * mod + a[i];
} else if ((n - 1) * (mod - n) >= (long long int)(-1e18)) {
cout << (n - 1) * (mod - n) << ' ';
a[i] = (n - 1) * (mod - n) + a[i];
}
}
cout << endl;
cout << 1 << ' ' << n << endl;
for (int i = 0; i < n; i++) {
cout << -a[i] << ' ';
}
cout << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void solve() {
long long n;
cin >> n;
vector<long long> arr(n);
for (long long i = 0; i < n; i++) cin >> arr[i];
if (n == 1) {
cout << 1 << ' ' << 1 << endl;
cout << 0 << endl;
cout << 1 << ' ' << 1 << endl;
cout << 0 << endl;
cout << 1 << ' ' << 1 << endl;
cout << -arr[0] << endl;
return;
}
cout << 1 << ' ' << 1 << endl;
cout << -arr[0] << endl;
cout << 1 << ' ' << n << endl;
cout << 0 << ' ';
for (long long i = 1; i < n; i++) cout << -(n * arr[i]) << ' ';
cout << endl;
cout << 2 << ' ' << n << endl;
for (long long i = 1; i < n; i++) cout << (n - 1) * arr[i] << ' ';
cout << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
vector<long long> v(n, 0);
for (int i = 0, _n = (n); i < _n; i++) cin >> v[i];
if (n == 1) {
cout << 1 << " " << n << '\n';
cout << -v[0] << '\n';
for (int i = 0, _n = (2); i < _n; i++) {
cout << 1 << " " << n << '\n';
cout << 0 << '\n';
}
}
if (n > 1) {
cout << 1 << " " << n - 1 << '\n';
for (int i = 0, _n = (n - 1); i < _n; i++) {
cout << v[i] * (n - 1) << ' ';
v[i] += v[i] * (n - 1);
}
cout << '\n';
cout << n << " " << n << '\n';
cout << -v[n - 1] << '\n';
v[n - 1] = 0;
cout << 1 << " " << n << '\n';
for (int i = 0, _n = (n); i < _n; i++) {
cout << -v[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) cin >> a[i];
cout << 1 << " " << 1 << '\n';
cout << -a[0] << '\n';
a[0] = 0;
if (n == 1) {
for (int i = 0; i < 2; i++) cout << 1 << " " << 1 << '\n' << 0 << '\n';
return 0;
}
cout << 2 << " " << n << '\n';
for (int i = 1; i < n; i++) {
long long add = (a[i] % n) * (n - 1);
a[i] += add;
cout << add << " ";
}
cout << '\n' << 1 << " " << n << '\n';
for (int i = 0; i < n; i++) cout << -a[i] << " ";
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
if (a == 0) {
*x = 0;
*y = 1;
return b;
}
long long x1, y1;
long long gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
void diophantine(long long a, long long b, long long c, long long *c1,
long long *c2) {
long long x, y;
long long d = gcdExtended(a, b, &x, &y);
c = c / d;
*c1 = x * c;
*c2 = y * c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
long long n;
cin >> n;
long long aa[n], bb[n], cc[n];
for (long long i = 0; i <= n - 1; i++) cin >> aa[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -1 * aa[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return 0;
}
for (int i = 0; i < n; i++) {
long long x, y;
diophantine(n, n - 1, aa[i] * -1, &x, &y);
bb[i] = x * n;
cc[i] = y * (n - 1);
if (i == n - 1) {
diophantine(n, 1, aa[i] * -1, &x, &y);
bb[i] = x * n;
cc[i] = y;
}
}
cout << 1 << " " << n << endl;
for (long long i = 0; i <= n - 1; i++) cout << bb[i] << " ";
cout << endl;
cout << 1 << " " << n - 1 << endl;
for (long long i = 0; i <= n - 2; i++) cout << cc[i] << " ";
cout << endl;
cout << n << " " << n << endl;
cout << cc[n - 1] << endl;
}
|
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 2000000000;
const long long LINF = 2000000000000000000;
template <typename T>
void print(vector<T>& a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
cout << '\n';
}
template <typename T>
void print(deque<T>& a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
cout << '\n';
}
template <typename T>
void print(vector<vector<T>>& a) {
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
cout << '\n';
}
}
template <typename T>
void input(vector<T>& a) {
for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(deque<T>& a) {
for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(vector<vector<T>>& a) {
for (int i = 0; i < a.size(); i++)
for (int j = 0; j < a[i].size(); j++) cin >> a[i][j];
}
void solve() {
int n;
cin >> n;
vector<long long> a(n);
input(a);
if (n == 1) {
cout << 1 << ' ' << 1 << '\n';
cout << -a[0] << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0;
} else {
cout << 1 << ' ' << n << '\n';
for (int i = 0; i < n; i++) cout << -a[i] * n << ' ';
cout << '\n';
cout << 1 << ' ' << n - 1 << '\n';
for (int i = 0; i < n - 1; i++) cout << a[i] * (n - 1) << ' ';
cout << '\n';
cout << n << ' ' << n << '\n';
cout << a[n - 1] * (n - 1);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tst = 1;
while (tst--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int inf2 = inf * inf;
priority_queue<long long int, vector<long long int>, greater<long long int>>
mnheap;
long long int gcd(long long int x, long long int y) {
if (x == 0) return y;
return gcd(y % x, x);
}
int is_prime(long long int x) {
if (x < 2) return 0;
for (long long int i = 2; i * i <= x; i++) {
if (x % i == 0) return 0;
}
return 1;
}
inline long long int modpw(long long int x, long long int y, long long int z) {
long long int res = 1;
x = x % z;
while (y) {
if (y & 1) res = (res * x) % z;
x = (x * x) % z;
y /= 2;
}
return res;
}
inline long long int modinv(long long int x, long long int z) {
return modpw(x, z - 2, z);
}
long long int lcm(long long int x, long long int y) {
return (x * y) / gcd(x, y);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
while (t--) {
int n;
cin >> n;
long long int x;
vector<long long int> vv;
for (int i = 0; i < n; i++) {
cin >> x;
vv.push_back(x);
}
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -vv[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return 0;
}
cout << 1 << " " << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
cout << vv[i] * (n - 1) << " ";
}
cout << endl;
cout << n << " " << n << endl;
cout << vv[n - 1] * (n - 1) << endl;
cout << 1 << " " << n << endl;
for (int i = 0; i < n; i++) {
cout << -1 * vv[i] * n << " ";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[100005];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
{
long long n;
cin >> n;
for (long long i = 1; i <= (n); ++i) cin >> a[i];
if (n == 1) {
cout << "1 1\n" << -a[1] << endl;
cout << "1 1\n0\n1 1\n0";
return 0;
}
if (1) {
cout << "1 1\n";
cout << n - a[1] << endl;
a[1] = n;
cout << "2 " << n << endl;
for (long long i = 2; i <= (n); ++i) {
long long p = n - a[i];
cout << -p * (n - 1) << " ";
a[i] = a[i] - p * (n - 1);
}
cout << endl;
cout << "1 " << n << endl;
for (long long i = 1; i <= (n); ++i) cout << -a[i] << " ";
} else {
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
vector<long long> v(n, 0);
for (int i = 0, _n = (n); i < _n; i++) cin >> v[i];
if (n == 1) {
cout << 1 << " " << n << '\n';
cout << -v[0] << '\n';
cout << 1 << " " << n << '\n';
cout << 0 << '\n';
cout << 1 << " " << n << '\n';
cout << 0 << '\n';
}
if (n > 1) {
cout << 1 << " " << n - 1 << '\n';
for (int i = 0, _n = (n - 1); i < _n; i++) {
cout << v[i] * (n - 1) << ' ';
v[i] += v[i] * (n - 1);
}
cout << '\n';
cout << n << " " << n << '\n';
cout << -v[n - 1] << '\n';
v[n - 1] = 0;
cout << 1 << " " << n << '\n';
for (int i = 0, _n = (n); i < _n; i++) {
cout << -v[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int MAX = 1e4 + 7;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n;
cin >> n;
vector<long long> a(n, 0);
for (int i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << "\n";
cout << -a[0] << "\n";
cout << 1 << " " << 1 << "\n";
cout << 0 << "\n";
cout << 1 << " " << 1 << "\n";
cout << 0;
} else {
cout << 1 << " " << n - 1 << "\n";
for (int i = 0; i < n - 1; i++) {
cout << a[i] * (n - 1) << " ";
a[i] *= n;
}
cout << "\n";
cout << n << " " << n << "\n";
cout << a[n - 1] * (n - 1) << "\n";
a[n - 1] *= n;
cout << 1 << " " << n << "\n";
for (int i = 0; i < n; i++) cout << -a[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<long long> a(n);
for (auto& x : a) cin >> x;
if (n >= 3) {
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
cout << 1 << " " << n << endl;
a[0] = 0;
int m = n;
for (int i = 0; i < n; i++) {
if (i > 0) cout << " ";
cout << -1LL * m * a[i];
a[i] -= 1LL * m * a[i];
}
cout << endl;
m = n - 1;
cout << 2 << " " << n << endl;
for (int i = 1; i < n; i++) {
if (i > 1) cout << " ";
assert(a[i] % m == 0);
cout << -1LL * a[i];
}
cout << endl;
} else if (n == 2) {
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
cout << 2 << " " << 2 << endl;
cout << 1 << endl;
a[1]++;
cout << 2 << " " << 2 << endl;
cout << -a[1] << endl;
} else if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 1 << endl;
cout << 1 << " " << 1 << endl;
cout << -1 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, a[100001], sum, tong = 0, res = 1e18;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -a[1] << endl;
cout << 1 << " " << 1 << endl;
cout << a[1] << endl;
cout << 1 << " " << 1 << endl;
cout << -a[1] << endl;
return 0;
}
cout << 1 << " " << n << endl;
for (int i = 1; i <= n; i++) cout << -(n * a[i]) << " ";
cout << endl;
cout << 1 << " " << n - 1 << endl;
for (int i = 1; i < n; i++) cout << ((n - 1) * a[i]) << " ";
cout << endl;
cout << n << " " << n << endl;
cout << -(a[n] - n * a[n]) << endl;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
using namespace std;
void huehue(istream_iterator<string> it) {}
template <typename T, typename... Args>
void huehue(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << ", ";
huehue(++it, args...);
}
template <class T>
T inf() {
return numeric_limits<T>::max();
}
void read() { return; }
void print() { return; }
void println() {
cout << "\n";
return;
}
template <class T>
T read(T &x) {
cin >> x;
return x;
}
template <class T>
void print(T a) {
cout << a;
}
template <class T>
void println(T a) {
cout << a << "\n";
}
template <class T>
void read(vector<T> &arr) {
for (auto &i : arr) cin >> (i);
}
template <class T>
void print(vector<T> arr) {
for (auto &i : arr) {
cout << i << " ";
}
}
template <class T>
void println(vector<T> arr) {
for (auto &i : arr) {
cout << i << " ";
}
cout << "\n";
}
template <class T>
void read(vector<vector<T>> &arr) {
for (auto &i : arr) read(i);
}
template <class T>
void print(vector<vector<T>> arr) {
for (auto &i : arr) println(i);
}
template <class T>
void println(vector<vector<T>> arr) {
for (auto &i : arr) println(i);
}
template <typename T, typename... Args>
void read(vector<T> &arr, Args &...args) {
read(arr);
read(args...);
}
template <typename T, typename... Args>
void read(vector<vector<T>> &arr, Args &...args) {
read(arr);
read(args...);
}
template <typename T, typename... Args>
void read(T &a, Args &...args) {
cin >> (a);
read(args...);
}
template <typename T, typename... Args>
void print(vector<T> &arr, Args &...args) {
print(arr);
print(args...);
}
template <typename T, typename... Args>
void print(T a, Args... args) {
cout << a << " ";
print(args...);
};
template <typename T, typename... Args>
void println(vector<T> &arr, Args &...args) {
print(arr);
println(args...);
}
template <typename T, typename... Args>
void println(T a, Args... args) {
cout << a << " ";
println(args...);
};
const long long int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const long long int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1},
d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void solveEachTest(long long int _TestCase = 1) {
long long int n;
read(n);
vector<long long int> arr(n);
read(arr);
if (n == 1) {
println(1, 1);
println(-arr[0]);
println(1, 1);
println(0);
println(1, 1);
println(0);
return;
}
println(1, 1);
for (auto i = (0); (((1) > 0) ? (i) < (1) : (i) > (1)); (i) += (1)) {
cout << -arr[i] << " ";
arr[i] = 0;
}
println();
println(2, n);
for (auto i = (1); (((1) > 0) ? (i) < (n) : (i) > (n)); (i) += (1)) {
cout << (n - 1) * arr[i] << " ";
arr[i] += (arr[i] * (n - 1));
}
println();
println(1, n);
for (auto i = (0); (((1) > 0) ? (i) < (n) : (i) > (n)); (i) += (1)) {
cout << -arr[i] << " ";
}
cout << "\n";
return;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
long long int T3X0 = 0, T353 = 1;
solveEachTest(T353 - T3X0);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
void faster() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
void solve() {
long long n;
cin >> n;
vector<long long> a(n);
for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
i += 1 - 2 * ((0) > (n)))
cin >> a[i];
cout << 1 << " " << 1 << endl;
cout << -1 * a[0] << endl;
a[0] = 0;
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return;
}
cout << 2 << " " << n << endl;
for (__typeof(n) i = (1) - ((1) > (n)); i != (n) - ((1) > (n));
i += 1 - 2 * ((1) > (n))) {
cout << (n - 1) * a[i] << " ";
a[i] += (n - 1) * a[i];
}
cout << endl;
cout << 1 << " " << n << endl;
for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
i += 1 - 2 * ((0) > (n)))
cout << -1 * a[i] << " ";
cout << endl;
}
signed main() {
faster();
long long t = 1;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e5 + 100;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
long long a[MAX], b[MAX], c[MAX];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long tc, n;
string s;
tc = 1;
while (tc--) {
cin >> n;
for (long long i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << "1 1\n" << -a[0] << endl;
cout << "1 1\n"
<< "0\n";
cout << "1 1\n"
<< "0\n";
return 0;
}
for (long long i = 0; i < n - 1; i++) {
b[i] = (a[i] % (n - 1));
c[i] = (a[i] - b[i] * n) / (n - 1);
}
cout << "1 " << n << endl;
for (long long i = 0; i < n; i++) cout << -b[i] * (n) << " ";
cout << endl;
cout << "1 " << n - 1 << endl;
for (long long i = 0; i < n - 1; i++) cout << -c[i] * (n - 1) << " ";
cout << endl;
cout << n << " " << n << endl;
cout << -a[n - 1];
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<long long> a(n + 1);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
}
int num1 = n - 1;
if (n == 1) {
printf("1 1\n");
printf("%lld\n", a[1] * -1);
printf("1 1\n");
printf("0\n");
printf("1 1\n");
printf("0\n");
return 0;
}
printf("1 %d\n", num1);
for (int i = 1; i <= num1; i++) {
if (i != 1) printf(" ");
printf("%lld", a[i] * num1);
a[i] = a[i] + a[i] * num1;
}
printf("\n");
printf("2 %d\n", n);
for (int i = 2; i <= n; i++) {
if (i != 2) printf(" ");
if (i != n)
printf("0");
else {
printf("%lld", a[i] * (n - 1));
a[i] = a[i] + a[i] * (n - 1);
}
}
printf("\n");
printf("1 %d\n", n);
for (int i = 1; i <= n; i++) {
if (i != 1) printf(" ");
printf("%lld", a[i] * -1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int OFF = (1 << 20);
int n;
long long a[100002];
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
cout << "1 1\n" << -a[0] << "\n";
a[0] = 0;
if (n == 1)
cout << "1 1\n0\n";
else {
cout << "2 " << n << "\n";
for (int i = 1; i < n; i++) {
long long tren = n - 1;
tren *= a[i];
a[i] += tren;
cout << tren << " ";
}
cout << "\n";
}
cout << "1 " << n << "\n";
for (int i = 0; i < n; i++) {
cout << -a[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e12;
const long long N = 100005;
void solve() {
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << n << endl;
long long zz = (-1) * a[0];
cout << zz;
cout << endl;
cout << 1 << " " << 1 << endl;
cout << 0;
cout << endl;
cout << n << " " << n << endl;
cout << 0 << endl;
return;
}
vector<long long> v;
for (long long i = 0; i < n; i++) {
long long y = 0;
if (a[i] < 0) {
y = a[i] / n;
y *= -1;
y++;
a[i] += n * y;
}
long long x = a[i] % (n - 1);
x = (n - 1) - x;
a[i] += n * x;
v.push_back(n * (x + y));
}
vector<long long> v1;
for (long long i = 0; i < n - 1; i++) {
long long x = a[i] / (n - 1);
x *= -1;
v1.push_back(x * (n - 1));
}
cout << 1 << " " << n << endl;
for (long long i = 0; i < n; i++) {
cout << v[i] << " ";
}
cout << endl;
cout << 1 << " " << n - 1 << endl;
for (long long i = 0; i < n - 1; i++) {
cout << v1[i] << " ";
}
cout << endl;
cout << n << " " << n << endl;
long long z = a[n - 1] * (-1);
cout << z << endl;
return;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using dl = double;
const int N = 2e5 + 10;
ll aarray[200000 + 10];
ll magic[101][101];
vector<ll> primes;
bool prime[1000001];
int main() {
ios_base::sync_with_stdio(false);
string str;
ll i, j, n, m, k, t;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> aarray[i];
}
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << -aarray[1] << endl;
return 0;
}
cout << 1 << " " << n << endl;
for (i = 1; i <= n; i++) {
cout << -(aarray[i] * n) << " ";
}
cout << endl;
cout << 1 << " " << n - 1 << endl;
for (i = 1; i < n; i++) {
cout << aarray[i] * (n - 1) << " ";
}
cout << endl;
cout << n << " " << n << endl;
k = -(aarray[n] * n);
cout << -(k + aarray[n]) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const long long Inf = 0x7f7f7f7f7f7f7f;
const long long mod = 1e6 + 3;
bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }
int modPowerOfTwo(int x, int mod) { return x & (mod - 1); }
int getBit(int a, int b) { return (a >> b) & 1; }
int Max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }
int Min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int Abs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res % mod;
}
void extend_gcd(long long a, long long b, long long &x, long long &y) {
if (b == 0) {
x = 1, y = 0;
return;
}
extend_gcd(b, a % b, x, y);
long long tmp = x;
x = y;
y = tmp - (a / b) * y;
}
long long mod_inverse(long long a, long long m) {
long long x, y;
extend_gcd(a, m, x, y);
return (m + x % m) % m;
}
long long eulor(long long x) {
long long cnt = x;
long long ma = sqrt(x);
for (int i = 2; i <= ma; i++) {
if (x % i == 0) cnt = cnt / i * (i - 1);
while (x % i == 0) x /= i;
}
if (x > 1) cnt = cnt / x * (x - 1);
return cnt;
}
long long t, n, a[maxn], b[maxn];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
for (int i = 2; i <= 3; i++) {
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
}
return 0;
}
cout << 1 << " " << n - 1 << "\n";
for (int i = 1; i <= n - 1; i++) {
cout << (n - 1) * a[i] << " ";
a[i] += (n - 1) * a[i];
}
cout << endl;
cout << n << " " << n << '\n';
cout << -a[n] << '\n';
cout << 1 << " " << n << '\n';
for (int i = 1; i < n; i++) cout << -a[i] << " ";
cout << 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<long long> as(n, 0);
for (int i = 0; i < n; i++) cin >> as[i];
if (n == 1) {
cout << "1 1\n" << -as[0] << "\n";
cout << "1 1\n0\n1 1\n0\n";
return 0;
}
int len = n - 1;
cout << "1 " << len << "\n";
for (int i = 0; i < len; i++) {
cout << (long long)(as[i] % n) * len;
if (i < len - 1) cout << " ";
as[i] += (as[i] % n) * len;
}
cout << "\n" << n << " " << n << "\n" << -as[len] + n << "\n";
as[len] -= as[len] - n;
cout << "1 " << n << "\n";
for (int i = 0; i < n; i++) {
cout << -as[i];
if (i < n - 1) cout << " ";
}
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double pi = 4 * atan((long double)1);
const long long mod = 1e9 + 7;
const long long inf = 922337203685477;
const long long nax = 1e5 + 5;
long long n;
long long a[nax], p[nax];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (long long i = 1; i <= n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << "1 1\n";
cout << 0 << '\n';
cout << "1 1\n";
cout << 0 << '\n';
cout << "1 1\n";
cout << -a[n] << '\n';
return 0;
}
long long cur = 0;
for (long long i = 1; i <= n + 5; i++) {
p[cur % n] = cur;
cur += n - 1;
}
cout << 1 << " " << n - 1 << '\n';
for (long long i = 1; i <= n - 1; i++) {
if (a[i] % n == 0) {
cout << 0 << " ";
} else {
if (a[i] < 0) {
long long temp = a[i] % n;
temp += n;
a[i] += -p[temp];
cout << -p[temp] << " ";
} else {
long long temp = a[i] % n;
temp = n - temp;
a[i] += p[temp];
cout << p[temp] << " ";
}
}
}
cout << '\n';
cout << n << " " << n << '\n';
if (a[n] == 0) {
cout << 0 << '\n';
} else if (a[n] < 0) {
cout << -a[n] << '\n';
a[n] = 0;
} else {
cout << -a[n] << '\n';
a[n] = 0;
}
cout << 1 << " " << n << '\n';
for (long long i = 1; i <= n; i++) {
if (a[i] <= 0) {
cout << abs(a[i]) << " ";
} else {
cout << -a[i] << " ";
}
}
cout << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
vector<long long int> v;
for (int i = 0; i < n; i++) {
long long int x;
cin >> x;
v.push_back(x);
}
if (n > 1) {
cout << "1 1" << endl;
cout << (long long int)(-1) * v[0] << endl;
cout << "1 " << n << endl;
cout << "0 ";
for (int i = 1; i < n; i++) {
cout << (long long int)(-1) * n * v[i] << " ";
}
cout << endl;
cout << "2 " << n << endl;
for (int i = 1; i < n; i++) {
cout << (long long int)(n - 1) * v[i] << " ";
}
cout << endl;
} else {
cout << "1 1" << endl;
cout << (-1) * v[0] << endl;
cout << "1 1" << endl;
cout << 0 << endl;
cout << "1 1" << endl;
cout << 0 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int a[100007];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
cout << "1 1" << endl << a[1] * (n - 1) << endl;
if (n == 1)
cout << "1 1" << endl << "0" << endl;
else
cout << 2 << " " << n << endl;
for (int i = 2; i <= n; i++) cout << a[i] * (n - 1) << " ";
cout << endl << 1 << " " << n << endl;
for (int i = 1; i <= n; i++) cout << -a[i] * n << " ";
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
return b ? power(a * a % 1000000007ll, b / 2) * (b % 2 ? a : 1) % 1000000007ll
: 1;
}
long long gcd(long long a, long long b) {
if (a == 0 || b == 0) return max(a, b);
if (a == 1 || b == 1) return 1;
return gcd(max(a, b) % min(a, b), min(a, b));
}
void solve() {
long long n;
cin >> n;
vector<long long> a(n, 0);
for (int i = 0; i < int(n); i++) cin >> a[i];
map<long long, long long> m;
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -1 * a[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return;
}
for (int i = 1; i <= n - 1; i++) {
m[((n - 1) * i) % n] = (n - 1) * i;
}
cout << 1 << " " << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
int curr = a[i] % n;
if (curr < 0) curr += n;
cout << m[n - curr] << " ";
a[i] += m[n - curr];
}
cout << endl;
cout << n << " " << n << endl;
cout << -1 * a[n - 1] << endl;
a[n - 1] = 0;
cout << 1 << " " << n << endl;
for (int i = 0; i < n; i++) cout << -1 * a[i] << " ";
cout << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
long long n;
cin >> n;
vector<long long> v(n);
for (long long &i : v) cin >> i;
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
cout << 1 << " " << 1 << '\n';
cout << -v[0] << '\n';
} else {
cout << 1 << " " << n << '\n';
for (int i = 0; i < n; i++) cout << -n * v[i] << " \n"[i == n - 1];
cout << 2 << " " << n << '\n';
for (int i = 1; i < n; i++) cout << (n - 1) * v[i] << " \n"[i == n - 1];
cout << 1 << " " << 1 << '\n';
cout << (n - 1) * v[0];
}
}
|
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
template <typename T>
void print(vector<T>& a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
cout << "\n";
}
template <typename T>
void print(deque<T>& a) {
for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
cout << "\n";
}
template <typename T>
void print(vector<vector<T>>& a) {
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < a[i].size(); j++) cout << a[i][j];
cout << "\n";
}
}
template <typename T>
void input(vector<T>& a) {
for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(deque<T>& a) {
for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(vector<vector<T>>& a) {
for (int i = 0; i < a.size(); i++)
for (int j = 0; j < a[i].size(); j++) cin >> a[i][j];
}
const long long INF = 1e9;
const long long MOD = 1e9 + 9;
const int NMAX = (1 << 16);
long double eps = 0.000000000001;
void solve() {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << 1 << " " << 1 << "\n";
cout << 1 << "\n";
cout << 1 << " " << 1 << "\n";
cout << 1 << "\n";
cout << 1 << " " << 1 << "\n";
cout << -(a[0] + 2);
} else {
cout << 1 << " " << n << "\n";
for (int i = 0; i < n; i++) {
cout << -a[i] * n << " ";
}
cout << "\n";
cout << 1 << " " << n - 1 << "\n";
for (int i = 0; i < n - 1; i++) {
cout << a[i] * (n - 1) << " ";
}
cout << "\n";
cout << n << " " << n << "\n";
cout << a[n - 1] * (n - 1) << "\n";
}
}
int main() {
srand(time(0));
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int64_t a[100000];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int64_t n;
cin >> n;
for (uint64_t i = 0; i < n; ++i) {
cin >> a[i];
}
if (n == 1) {
cout << "1 1" << '\n';
cout << -a[0] << '\n';
cout << "1 1" << '\n';
cout << '0' << '\n';
cout << "1 1" << '\n';
cout << '0' << '\n';
} else {
cout << "1 1" << '\n';
cout << -a[0] << '\n';
a[0] = 0;
cout << "2 " << n << '\n';
for (uint64_t i = 1; i < n; ++i) {
cout << ((n - 1) * (a[i] % n)) << ' ';
a[i] = a[i] + (n - 1) * (a[i] % n);
}
cout << '\n';
cout << "1 " << n << '\n';
for (uint64_t i = 0; i < n; ++i) {
cout << -a[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout.precision(20);
long long int n;
cin >> n;
vector<long long int> a(n);
for (long long int i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << ' ' << 1 << '\n';
cout << -1 * a[0] << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
return 0;
}
cout << 1 << ' ' << n - 1 << '\n';
for (long long int i = 0; i < n - 1; i++) {
long long int diff = 0;
long long int f = (a[i] % (n - 1));
diff += f - a[i];
a[i] += diff;
if (a[i] < 0) {
a[i] += 2 * (n - 1);
diff += 2 * (n - 1);
}
f = a[i] % n;
diff += f * (n - 1);
a[i] += f * (n - 1);
cout << diff << ' ';
}
cout << '\n';
cout << n << ' ' << n << '\n';
cout << -1 * a[n - 1] << '\n';
a[n - 1] = 0;
cout << 1 << ' ' << n << '\n';
for (long long int i = 0; i < n; i++) {
cout << -a[i] << ' ';
}
cout << '\n';
;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int a[N];
long long ans[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << -a[1] << '\n';
return 0;
}
for (int i = 1; i <= n; i++) {
long long x = a[i];
long long yu = x % (n - 1);
long long byu = (n - 1 - yu) * n;
ans[i] = byu + a[i];
}
cout << 1 << ' ' << n << '\n';
for (int i = 1; i <= n; i++) {
cout << ans[i] - a[i] << ' ';
}
cout << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << -ans[1] << '\n';
cout << 2 << ' ' << n << '\n';
for (int i = 2; i <= n; i++) {
cout << -ans[i] << ' ';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool f = 1;
string r = "{";
for (const auto& x : v) {
if (!f) r += ", ";
f = 0;
r += to_string(x);
}
return r + "}";
}
void debug_out() { cout << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cout << " " << to_string(H);
debug_out(T...);
}
const long double eps = 1e-7;
const long long mod = 1000000007;
const long long N = 998244353;
long long binpow(long long b, long long p) {
long long ans = 1;
while (p > 0) {
if (p & 1) ans = (ans * b) % mod;
b = (b * b) % mod;
p >>= 1;
}
return ans;
}
long long modinv(long long x) { return binpow(x, mod - 2); }
void solve() {
long long n, i;
cin >> n;
vector<long long> a(n);
for (i = 0; i < n; i++) cin >> a[i];
cout << "1 1" << '\n';
cout << -a[0] << '\n';
if (n == 1) {
cout << "1 1" << '\n';
cout << 0 << '\n';
cout << "1 1" << '\n';
cout << 0 << '\n';
return;
}
cout << "2 " << n << '\n';
for (i = 1; i < n; i++) {
cout << (n - 1) * a[i] << " ";
a[i] += (n - 1) * a[i];
}
cout << '\n';
cout << "1 " << n << '\n';
cout << 0 << " ";
for (i = 1; i < n; i++) {
cout << -a[i] << " ";
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1, i;
for (i = 0; i < t; i++) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[100010];
long long ss;
int main(void) {
scanf("%lld", &n);
for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
if (n == 1) {
printf("1 1\n%lld\n1 1\n0\n1 1\n0", a[1] * -1);
return 0;
}
ss = n - 1;
printf("1 %lld\n", n);
for (long long i = 1; i < n; i++) {
long long mo = a[i] % ss;
if (mo == 0) {
printf("0 ");
continue;
}
mo = ss - mo;
a[i] += n * mo;
printf("%lld ", n * mo);
}
printf("0\n1 %lld\n", n - 1);
for (long long i = 1; i < n; i++) printf("%lld ", a[i] * -1);
printf("\n%lld %lld\n%lld", n, n, a[n] * -1);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n;
cin >> n;
long long int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
if (n == 1) {
cout << "1 1\n1\n1 1\n1\n1 1\n-" << arr[0] + 2 << "\n";
return 0;
}
cout << "1 1\n" << n - arr[0] << "\n";
arr[0] = n;
cout << "2 " << n << "\n";
for (int i = 1; i < n; i++) {
cout << (n - 1) * (arr[i] % n) << " ";
arr[i] += (n - 1) * (arr[i] % n);
}
cout << "\n";
cout << "1 " << n << "\n";
for (int i = 0; i < n; i++) cout << (-1) * arr[i] << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void d_m_c() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
long long power(long long n, long long x) {
if (x == 0) return 1;
long long small = power(n, x / 2);
small = (small * small);
if (1 & x) small = (n * small);
return small;
}
int32_t main() {
d_m_c();
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
} else {
cout << 1 << " " << 1 << endl;
cout << -a[0] << endl;
a[0] = 0;
cout << 2 << " " << n << endl;
for (long long i = 1; i < n; i++) cout << a[i] * (n - 1) << " ";
cout << endl;
cout << 1 << " " << n << endl;
for (long long i = 0; i < n; i++) cout << -a[i] * n << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long A[100005];
signed main() {
long long n;
cin >> n;
for (long long i = 0; i < n; ++i) cin >> A[i];
if (n == 1) {
cout << "1 1" << endl
<< -A[0] << endl
<< "1 1" << endl
<< "0" << endl
<< "1 1" << endl
<< "0";
return 0;
}
cout << "1 " << n - 1 << endl;
for (long long i = 0; i < n - 1; ++i) cout << A[i] * (n - 1) << " ";
cout << endl;
cout << "1 " << n << endl;
for (long long i = 0; i < n; ++i) cout << -A[i] * n << " ";
cout << endl;
cout << n << " " << n << endl << A[n - 1] * (n - 1) << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << 1 << " " << max(1ll, n - 1) << "\n";
cout << (a[0] % n) * n - (a[0] % n) << " ";
a[0] += (a[0] % n) * n - (a[0] % n);
for (int i = 1; i < n - 1; i++) {
cout << "0 ";
}
cout << "\n";
cout << min(n, 2ll) << " " << n << "\n";
for (int i = 1; i < n - 1; i++) {
cout << (a[i] % n) * n - (a[i] % n) << " ";
a[i] += (a[i] % n) * n - (a[i] % n);
}
cout << (a[n - 1] % n) * n - (a[n - 1] % n) << "\n";
a[n - 1] += (a[n - 1] % n) * n - (a[n - 1] % n);
cout << 1 << " " << n << "\n";
for (int i = 0; i < n; i++) {
cout << -1 * (a[i]) << " ";
}
cout << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
long long maxPrimeFactors(long long n) {
long long maxPrime = -1;
while (n % 2 == 0) {
maxPrime = 2;
n >>= 1;
}
for (int i = 3; i <= sqrt(n); i += 2) {
while (n % i == 0) {
maxPrime = i;
n = n / i;
}
}
if (n > 2) maxPrime = n;
return maxPrime;
}
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long P(long long B, long long power, long long modulo) {
long long ans = 1LL;
while (power > 0LL) {
if (power % 2LL == 1LL) {
ans = (ans * B) % modulo;
}
B = (B * B) % modulo;
power /= 2LL;
}
return ans;
}
bool isPrime(long long n) {
if (n <= 1LL) {
return false;
}
if (n <= 3LL) {
return true;
}
if (n % 2 == 0LL || n % 3 == 0LL) {
return false;
}
for (long long i = 5LL; (i * i) <= n; i += 6LL) {
if (n % i == 0LL || n % (i + 2LL) == 0LL) {
return false;
}
}
return true;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
void combinationUtil(int arr[], int n, int r, int index, int data[], int i);
void printCombination(int arr[], int n, int r) {
int data[r];
combinationUtil(arr, n, r, 0, data, 0);
}
void combinationUtil(int arr[], int n, int r, int index, int data[], int i) {
if (index == r) {
for (int j = 0; j < r; j++) cout << data[j] << " ";
cout << endl;
return;
}
if (i >= n) return;
data[index] = arr[i];
combinationUtil(arr, n, r, index + 1, data, i + 1);
combinationUtil(arr, n, r, index, data, i + 1);
}
long long reccur(int arr[], int k, int n, int m, int start, int NoOfElements,
long long dp[][1005]) {
if (k == NoOfElements) {
return 0;
}
if (start == n) {
return 0;
}
if (dp[start][NoOfElements] != -1) {
return dp[start][NoOfElements];
}
long long take = arr[start] * ((NoOfElements + 1) % m) +
reccur(arr, k, n, m, start + 1, NoOfElements + 1, dp);
long long notTake = reccur(arr, k, n, m, start + 1, NoOfElements, dp);
long long qw = max(take, notTake);
return qw;
}
long long findlcm(int arr[], int n) {
long long ans = arr[0];
for (int i = 1; i < n; i++) ans = (((arr[i] * ans)) / (gcd(arr[i], ans)));
return ans;
}
unsigned long long int LCMmast(int arr[], int n) {
int max_num = 0;
for (int i = 0; i < n; i++)
if (max_num < arr[i]) max_num = arr[i];
unsigned long long int res = 1;
int x = 2;
while (x <= max_num) {
vector<int> indexes;
for (int j = 0; j < n; j++)
if (arr[j] % x == 0) indexes.push_back(j);
if (indexes.size() >= 2) {
for (int j = 0; j < indexes.size(); j++)
arr[indexes[j]] = arr[indexes[j]] / x;
res = res * x;
} else
x++;
}
for (int i = 0; i < n; i++) res = res * arr[i];
return res;
}
void printGolomb(int n, int l, int r) {
long long dp[n];
dp[1] = 1;
for (int i = 2; i <= n; i++) {
long long s = (1 + dp[i - dp[dp[i - 1]]]);
dp[i] = s;
}
vector<int> v(n + 1);
for (int i = 0; i < n; i++) {
v[i] = (dp[i + 1] * dp[i + 1]) % 1000000007;
}
std::vector<int> prefixSum(n + 1);
prefixSum[0] = v[0];
for (int i = 1; i < n; i++)
prefixSum[i] =
(prefixSum[i - 1] % 1000000007 + v[i] % 1000000007) % 1000000007;
long long ans = prefixSum[r - 1] - prefixSum[l - 2];
cout << ans << endl;
}
bool helper(std::vector<int> &v, int n, int m, int idx) {
if (idx == m) return 1;
if (idx >= n) return 0;
return helper(v, n, m, idx + v[idx]);
}
bool solve1(long long a, long long b, std::vector<long long> &res) {
if (b < a) {
return false;
}
if (a == b) {
res.push_back(b);
return true;
}
if (!(b & 1)) {
res.push_back(b);
return solve1(a, b / 2, res);
} else if (b % 10 == 1) {
res.push_back(b);
return solve1(a, (b - 1) / 10, res);
} else
return false;
}
pair<int, int> findEntryWithLargestValue(map<int, int> sampleMap) {
pair<int, int> entryWithMaxValue = make_pair(0, 0);
map<int, int>::iterator currentEntry;
for (currentEntry = sampleMap.begin(); currentEntry != sampleMap.end();
++currentEntry) {
if (currentEntry->second > entryWithMaxValue.second) {
entryWithMaxValue = make_pair(currentEntry->first, currentEntry->second);
}
}
return entryWithMaxValue;
}
int maxCountSameSUM(std::vector<int> arr, int n) {
unordered_map<int, int> M;
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++) M[(arr[i] + arr[j])]++;
int max_count = 0;
for (auto ele : M)
if (max_count < ele.second) max_count = ele.second;
return max_count;
}
void solvE2() {
long long n, curr = 0, ans = 0, now = 0;
cin >> n;
std::vector<long long> a(n);
for (auto &i : a) {
cin >> i;
}
sort(a.begin(), a.end());
std::vector<long long> v;
for (long long i = 0; i < n; ++i) {
for (long long j = i; j < n; j++) v.push_back(a[i] + a[j]);
}
for (auto x : v) {
now = 0;
int i = 0, j = n - 1;
while (i < j) {
if (a[i] + a[j] == x) {
now++, i++, j--;
} else if (a[i] + a[j] > x)
j--;
else
i++;
}
ans = max(ans, now);
}
cout << ans << endl;
}
int factmod(long long n, long long p) {
long long res = 1;
while (n > 1) {
res = (res * ((n / p) % 2 ? p - 1 : 1)) % p;
for (long long i = 2; i <= n % p; ++i) res = (res * i) % p;
n /= p;
}
return res % p;
}
unsigned int factorial(unsigned int n) {
if (n == 0) return 1;
return n * factorial(n - 1);
}
bool isSubsetSum(vector<int> &set, int n, int sum) {
bool subset[n + 1][sum + 1];
for (int i = 0; i <= n; i++) subset[i][0] = true;
for (int i = 1; i <= sum; i++) subset[0][i] = false;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= sum; j++) {
if (j < set[i - 1]) subset[i][j] = subset[i - 1][j];
if (j >= set[i - 1])
subset[i][j] = subset[i - 1][j] || subset[i - 1][j - set[i - 1]];
}
}
vector<int> ans;
for (int i = 0; i <= sum / 2; i++) {
if (subset[n][i] == 1) ans.push_back(i);
}
int mn = 99999999;
for (auto i : ans) {
mn = min(mn, sum - 2 * i);
}
return mn;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= sum; j++) cout << subset[i][j] << " ";
printf("\n");
}
}
int removeDigits(int n) {
int cnt = 0;
while (n) {
cnt++;
vector<int> digits;
int cpy = n;
while (cpy) {
digits.push_back(cpy % 10);
cpy /= 10;
}
n -= *max_element(digits.begin(), digits.end());
}
return cnt;
}
void coinChange() {
int n, x;
cin >> n >> x;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
int dp[n + 1][x + 1];
for (int i = 0; i <= x; i++) {
dp[0][i] = 0;
}
for (int i = 0; i <= n; i++) {
dp[i][0] = 1;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= x; j++) {
if (v[i - 1] <= j) {
dp[i][j] = (dp[i - 1][j] + dp[i][j - v[i - 1]]) % 1000000007;
} else {
dp[i][j] = (dp[i - 1][j]) % 1000000007;
}
}
}
cout << dp[n][x];
}
void solve() {}
int arrGCD(std::vector<int> &v, int n) {
if (n == 0) return -1;
int ans = v[0];
for (int i = 0; i < n; i++) {
ans = gcd(ans, v[i]);
if (ans == 1) return 1;
}
return ans;
}
int go(int n, int m) {
if (n == m) return 1;
if (n < 0) return 0;
}
int sw() {
int n, k;
cin >> n >> k;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
int limit = 0;
int moves = 0;
for (int i = 0; i < n; i++) {
if (v[i] > k) {
return -1;
}
if (limit + v[i] <= k) {
limit += v[i];
} else {
moves++;
limit = 0;
i--;
}
}
return moves + 1;
}
string solert() {
int n, k;
cin >> n >> k;
int n0, n1;
string s;
cin >> s;
for (auto i : s) {
if (i == '0')
n0++;
else
n1++;
}
bool w;
if (n1 > n0)
w = 1;
else
w = 0;
if (n & 1) {
int diff = abs(n0 - n1);
if (diff == n) {
string ans = "";
for (int i = 0; i < max(n0, n1); i++) {
if (w)
ans += "1";
else
ans += "0";
}
return ans;
} else if (diff == n - 2) {
string temp = "";
if (w) {
for (int i = 0; i < n / 2; i++) {
temp += "1";
}
temp += "0";
for (int i = 0; i < n / 2; i++) {
temp += "1";
}
} else {
for (int i = 0; i < n / 2; i++) {
temp += "0";
}
temp += "1";
for (int i = 0; i < n / 2; i++) {
temp += "0";
}
}
string ans = "";
for (int i = 0; i < n / k; i++) {
ans += temp;
}
return ans;
} else {
return "IMPOSSIBLE";
}
} else {
int diff = abs(n0 - n1);
if (diff == n) {
string ans = "";
for (int i = 0; i < max(n0, n1); i++) {
if (w)
ans += "1";
else
ans += "0";
}
return ans;
} else if (diff == 0) {
string ans = "";
string temp = "01";
for (int i = 0; i < n; i++) {
if (i & 1)
ans += "10";
else
ans += "01";
}
return ans;
} else {
return "IMPOSSIBLE";
}
}
}
void collectingPackages() {
int n;
string ans;
cin >> n;
std::vector<int> adj[1001];
int len = 0, bre = 0;
while (n--) {
int a, b;
cin >> a >> b;
len = max(len, a);
bre = max(bre, b);
adj[a].push_back(b);
}
for (int i = 0; i <= len; i++) {
sort(adj[i].begin(), adj[i].end());
}
int high = 0;
for (int i = 0; i <= len; i++) {
if (adj[i].size() > 0) {
int newHigh = adj[i].back();
if (newHigh < high) {
cout << "NO\n";
return;
}
for (int j = 0; j < newHigh - high; j++) ans += "U";
high = newHigh;
}
ans += "R";
}
cout << "YES\n";
ans.pop_back();
cout << ans << endl;
}
double getangleHour(int h, int m) {
if (h == 12) h = 0;
double pias = m * 1.0 / 2;
return h * 30 + pias;
}
double getangleMinute(int m) { return m * 6; }
double angleClock(int hour, int minutes) {
double d = abs(getangleMinute(minutes) - getangleHour(hour, minutes));
return min(d, 360 - d);
}
int longestCommonSubsequence(string text1, string text2) {
int m = text1.size();
int n = text2.size();
int output[m + 1][n + 1];
output[0][0] = 0;
for (int i = 1; i <= n; i++) output[0][i] = 0;
for (int i = 1; i <= m; i++) output[i][0] = 0;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (text1[m - i] == text2[n - j])
output[i][j] = 1 + output[i - 1][j - 1];
else {
int a = output[i - 1][j];
int b = output[i][j - 1];
int c = output[i - 1][j - 1];
output[i][j] = max(a, max(b, c));
}
}
}
return output[m][n];
}
void decToBinary(int n) {
if (n == 0) {
cout << "0";
return;
}
int binaryNum[32];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--) cout << binaryNum[j];
}
string decimalToBinary(int n) {
string s = bitset<64>(n).to_string();
const auto loc1 = s.find('1');
if (loc1 != string::npos) return s.substr(loc1);
return "0";
}
int p2(int x) {
int ans = 0;
while (x >= 1) {
ans++;
x /= 2;
}
return ans;
}
void solution23(int a, int b, int n) {
for (int i = 0; i * a <= n; i++) {
if ((n - (i * a)) % b == 0) {
cout << "x = " << i << ", y = " << (n - (i * a)) / b;
return;
}
}
cout << "No solution";
}
bool valid(int x, int n) { return x >= 0 and x < n; }
void reconsString() {
string s;
cin >> s;
int x;
cin >> x;
int n = s.size();
string ans = "";
for (int i = 0; i < s.size(); i++) {
ans += '1';
}
for (int i = 0; i < n; i++) {
if (s[i] == '0') {
if (valid(i + x, n)) ans[i + x] = '0';
if (valid(i - x, n)) ans[i - x] = '0';
}
}
bool works = 1;
for (int i = 0; i < n; i++) {
if (s[i] == '1') {
if (valid(i + x, n) and ans[i + x] == '1') continue;
if (valid(i - x, n) and ans[i - x] == '1') continue;
works = 0;
}
}
if (works) {
cout << ans << endl;
} else {
cout << "-1\n";
}
}
void sasa() {
int n;
cin >> n;
std::vector<int> v(n);
map<int, int> mp;
for (auto &i : v) {
cin >> i;
mp[i]++;
}
int cnt = 0;
for (int i = 0; i < n - 3; i++) {
for (int j = i + 1; j < n - 2; j++) {
for (int k = j + 1; k < n - 1; k++) {
for (int l = k + 1; l < n; l++) {
if (v[i] == v[k] and v[j] == v[l]) cnt++;
}
}
}
}
cout << cnt << endl;
}
int fact(int n) {
int res = 1;
for (int i = 2; i <= n; i++) res = res * i;
return res;
}
int nCr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); }
int edu92Helper(std::vector<int> &v, int idx, bool lastLeft, int z, int k) {
if (idx >= v.size() or idx < 0) return 0;
if (k == 0) return 0;
if (k > 0) {
if (lastLeft == 0 and z > 0) {
return max(edu92Helper(v, idx - 1, 1, z - 1, k - 1) + v[idx - 1],
edu92Helper(v, idx + 1, 0, z, k - 1) + v[idx + 1]);
}
return edu92Helper(v, idx + 1, 0, z, k - 1) + v[idx + 1];
}
}
void r529a() {
int n;
cin >> n;
string s;
cin >> s;
int jump = 0;
string ans = "";
for (int i = 0; i < s.size(); i += jump) {
ans += s[i];
jump++;
}
cout << ans << endl;
}
void prep2() {
long long m, n, x, y;
cin >> m >> n >> x >> y;
long long a = m * (y - 1) + x;
cout << "$ " << maxPrimeFactors(a) << endl;
}
void prep1() {
int n, k;
cin >> n >> k;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
long long totSum = 0;
for (int i = 0; i < n; i++) {
totSum += v[i];
}
int currSum = 0;
int idx = 0;
while (v[idx] != k and idx < n) {
currSum += v[idx];
idx++;
}
if (idx == n) {
cout << 0 << endl;
} else
cout << currSum << " " << totSum - currSum - v[idx] << endl;
;
}
void edu92() {
int n, k, z;
cin >> n >> k >> z;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
cout << edu92Helper(v, 0, 0, z, k) + v[0] << endl;
}
void r306b() {
string s;
cin >> s;
bool ok1 = 0, ok2 = 0;
int past = -1;
for (int i = 0; i < s.size(); i++) {
cout << i << " " << past << endl;
if (s[i] == 'A' and i <= s.size() - 2 and past != i)
if (s[i + 1] == 'B') ok1 = 1, past = i + 1;
if (s[i] == 'B' and i <= s.size() - 2 and past != i)
if (s[i + 1] == 'A') ok2 = 1, past = i + 1;
}
if (ok1 and ok2)
cout << "YES";
else
cout << "NO";
}
double r272b() {
string s1;
string s2;
cin >> s1 >> s2;
double qw = 0;
for (auto i : s1) {
if (i == '+')
qw++;
else
qw--;
}
double curr = 0;
double qcnt = 0;
for (auto i : s2) {
if (i == '+')
curr++;
else if (i == '-')
curr--;
else
qcnt++;
}
cout << abs(qw) - abs(curr) << endl;
cout << qcnt << endl;
if (abs(abs(qw) - abs(curr)) > qcnt)
return 0.0;
else if (abs(qw) - abs(curr) == qcnt)
return (1);
else {
double sas = (double)nCr(qcnt, abs(qw) - abs(curr)) / pow(2, s1.size());
return sas;
}
}
void r529b() {
int n;
cin >> n;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
sort(v.begin(), v.end());
cout << min(v[n - 2] - v[0], v[n - 1] - v[1]);
}
void r529c() {
int n, k;
cin >> n >> k;
int w = __builtin_popcount(n);
if (w > k) {
cout << "NO";
} else {
cout << "YES\n";
int toDiv = k - w;
}
}
void r666a() {
int n;
cin >> n;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
int freq[27] = {0};
for (int i = 0; i < n; i++) {
for (int j = 0; j < s[i].size(); j++) {
freq[s[i][j] - 'a']++;
}
}
bool works = 1;
for (int i = 0; i < 26; i++) {
if (freq[i] % n == 0 or freq[i] == 0) continue;
works = 0;
}
if (works)
cout << "YES\n";
else
cout << "NO\n";
}
void r666b() {
int n;
cin >> n;
std::vector<int> v(n);
for (auto &i : v) {
cin >> i;
}
sort(v.begin(), v.end());
}
void r666c() {
int n;
cin >> n;
std::vector<long long> v(n);
for (auto &i : v) {
cin >> i;
}
if (v.size() == 1) {
cout << "1 1\n0\n1 1\n0\n1 1\n";
cout << -1 * v[0];
return;
}
cout << "1 " << n << "\n";
for (int i = 0; i < n - 1; i++) {
cout << (n * -1 * v[i]) << " ";
}
cout << 0;
cout << endl;
cout << "1 " << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
cout << ((n - 1) * 1 * v[i]) << " ";
}
cout << endl;
cout << n << " " << n << endl;
;
cout << -1 * v[n - 1];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
t = 1;
while (t--) {
r666c();
}
}
|
#include <bits/stdc++.h>
using namespace std;
void egcd(int a, int b, int64_t& x, int64_t& y) {
if (a == 0) {
x = 0;
y = 1;
return;
}
int64_t tx, ty;
egcd(b % a, a, tx, ty);
x = ty - tx * (b / a);
y = tx;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int& v : a) cin >> v;
if (n == 1) {
cout << "1 1\n" << -a[0] << "\n1 1\n0\n1 1\n0\n";
return 0;
}
cout << "1 1\n" << -a[0] << "\n2 " << n << '\n';
int64_t x, y;
vector<int64_t> b(n);
for (int i = 1; i < n; ++i) {
egcd(n - 1, n, x, y);
b[i] = -y * a[i] * n;
cout << -x * a[i] * (n - 1) << ' ';
}
cout << "\n1 " << n << '\n';
for (int64_t v : b) cout << v << ' ';
cout << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long INF = 1e15;
const int N = 1e4 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tests = 1;
while (tests--) {
int n;
cin >> n;
vector<long long> arr(n);
for (int i = 0; i < n; i++) cin >> arr[i];
if (n == 1) {
cout << "1 1" << endl;
cout << (-1) * arr[0] << endl;
cout << "1 1" << endl;
cout << "0" << endl;
cout << "1 1" << endl;
cout << "0" << endl;
} else {
long long len1 = n - 1;
cout << "1 " << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
if (arr[i] % n == 0) {
cout << "0 ";
} else {
long long val = arr[i] % n;
cout << val * (n - 1) << " ";
arr[i] += val * (n - 1);
}
}
cout << endl;
cout << n << " " << n << endl;
cout << (-1) * arr[n - 1] << endl;
arr[n - 1] = 0;
cout << "1 " << n << endl;
for (int i = 0; i < n; i++) cout << (-1) * arr[i] << " ";
cout << endl;
}
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long MX = 2e5 + 5;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
const long long xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
template <class T>
bool ckmin(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
return a < b ? a = b, 1 : 0;
}
constexpr long long pct(long long x) { return __builtin_popcount(x); }
constexpr long long bits(long long x) { return 31 - __builtin_clz(x); }
template <class T>
T cdiv(T a, T b) {
return a / b + !(a < 0 || a % b == 0);
}
long long fstTrue(function<bool(long long)> first, long long lo, long long hi) {
hi++;
assert(lo <= hi);
while (lo < hi) {
long long mid = (lo + hi) / 2;
first(mid) ? hi = mid : lo = mid + 1;
}
return lo;
}
template <class T>
void remDup(vector<T>& v) {
sort(begin(v), end(v));
v.erase(unique(begin(v), end(v)), end(v));
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
cerr << h;
if (sizeof...(t)) cerr << ", ";
DBG(t...);
}
void setIn(string S) { freopen(S.c_str(), "r", stdin); }
void setOut(string S) { freopen(S.c_str(), "w", stdout); }
void setIO(string S = "") {
ios_base::sync_with_stdio(0);
cin.tie(0);
if ((long long)(S).size()) {
setIn(S + ".in"), setOut(S + ".out");
}
}
int32_t main() {
setIO();
long long n;
cin >> n;
vector<long long> arr(n);
for (auto& x : arr) cin >> x;
if (n == 1) {
for (long long i = (0); i < (3); ++i) {
cout << 1 << " " << 1 << "\n";
cout << -arr[0] << "\n";
arr[i] = 0;
}
} else {
cout << 1 << " " << 1 << "\n";
cout << -arr[0] << "\n";
cout << 2 << " " << n << "\n";
for (long long i = (1); i < (n); ++i) cout << arr[i] * (n - 1) << " ";
cout << "\n";
cout << 1 << " " << n << "\n";
cout << 0 << " ";
for (long long i = (1); i < (n); ++i) cout << -arr[i] * n << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n = 0;
cin >> n;
vector<long long> v(n);
for (long long i = 0; i < n; i++) cin >> v[i];
cout << "1 1" << endl;
long long v0d = n - (v[0] % n);
cout << v0d << endl;
v[0] += v0d;
if (n == 1) {
cout << "1 1" << endl << -v[0] << endl;
cout << "1 1" << endl << 0 << endl;
} else {
cout << 2 << " " << n << endl;
for (long long i = 1; i < n; i++) {
long long mod = v[i] % n;
long long d = (mod) * (n - 1);
cout << d << " ";
v[i] += d;
}
cout << endl << 1 << " " << n << endl;
for (long long i = 0; i < n; i++) {
cout << -v[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b) { return a > b; }
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
vector<long long> v(n);
for (long long i = 0; i < n; i++) {
v[i] = (a[i] + (1000000000 * n)) % n;
}
if (n == 1) {
cout << 1 << " " << 1 << "\n";
cout << -a[0] << "\n";
cout << 1 << " " << 1 << "\n";
cout << 0 << "\n";
cout << 1 << " " << 1 << "\n";
cout << 0 << "\n";
return 0;
}
cout << 2 << " " << n << "\n";
for (long long i = 1; i < n; i++) {
a[i] += v[i] * (n - 1);
cout << v[i] * (n - 1) << " ";
}
cout << "\n";
cout << 1 << " " << 1 << "\n";
cout << -a[0] << "\n";
a[0] = 0;
cout << 1 << " " << n << "\n";
for (long long i = 0; i < n; i++) {
cout << -a[i] << " ";
}
cout << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
void solve();
int main() { solve(); }
void solve() {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << 1 << ' ' << 1 << '\n' << 0 << '\n';
cout << 1 << ' ' << 1 << '\n' << 0 << '\n';
cout << 1 << ' ' << 1 << '\n' << -a[0];
return;
}
map<int, long long> o;
long long x = n - 1;
for (int i = 0; o.find(x % n) == o.end(); i++, x += (n - 1)) {
o[x % n] = x;
}
cout << 1 << ' ' << n - 1 << '\n';
for (int i = 0; i < n - 1; i++) {
long long x = o[(n - (a[i] % n)) % n];
cout << x << ' ';
a[i] += x;
}
cout << '\n';
cout << 2 << ' ' << n << '\n';
for (int i = 1; i < n; i++) {
if (i == n - 1) {
long long x = o[(n - (a[i] % n)) % n];
cout << x << ' ';
a[i] += x;
continue;
}
cout << '0' << ' ';
}
cout << '\n';
cout << 1 << ' ' << n << '\n';
for (int i = 0; i < n; i++) {
cout << -a[i] << ' ';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin >> n;
vector<long long> arr(n);
long long i;
for (i = 0; i < n; i++) {
cin >> arr[i];
}
if (n != 1) {
cout << "1 " << n - 1 << endl;
for (i = 0; i < n - 1; i++) {
long long r = ((arr[i] % n) + n) % n;
cout << r * (n - 1) << " ";
arr[i] += (r * (n - 1));
}
cout << endl;
} else {
cout << "1 1" << endl;
cout << (-1 * arr[0]) << endl;
arr[0] = 0;
}
cout << n << " " << n << endl;
cout << (-1 * arr[n - 1]) << endl;
arr[n - 1] = 0;
cout << "1 " << n << endl;
for (i = 0; i < n; i++) {
cout << (-1 * arr[i]) << " ";
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<ll> arr(n);
for (ll& i : arr) cin >> i;
if (n == 1) {
cout << 1 << ' ' << 1 << endl;
cout << -arr[0] << endl;
cout << 1 << ' ' << 1 << endl;
cout << 0 << endl;
cout << 1 << ' ' << 1 << endl;
cout << 0 << endl;
} else {
cout << 1 << ' ' << n << endl;
for (auto i : arr) cout << -i * n << ' ';
cout << endl;
cout << 1 << ' ' << n - 1 << endl;
for (int i = 0; i < arr.size() - 1; i++) cout << arr[i] * (n - 1) << ' ';
cout << endl;
cout << n << ' ' << n << endl;
cout << -(arr.back() - arr.back() * n) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, a = INT_MIN, b = INT_MIN;
cin >> n;
vector<long long int> v(n);
for (long long int i = 0; i < n; i++) {
cin >> v[i];
}
if (n == 1) {
for (int i = 0; i < 3; i++) {
cout << 1 << " " << 1 << "\n";
cout << (-1) * v[0] << "\n";
v[0] = 0;
}
return 0;
}
cout << 1 << " " << n - 1 << "\n";
for (int i = 0; i < n - 1; i++) {
if (v[i] < 0) {
int a = v[i] % (n - 1);
cout << (abs(v[i]) + a * (n)) << " ";
v[i] = (a * (n));
continue;
}
cout << v[i] * (n - 1) << " ";
v[i] = v[i] * (n);
}
cout << "\n";
cout << n << " " << n << "\n";
cout << (-1) * v[n - 1] << "\n";
v[n - 1] = 0;
cout << 1 << " " << n << "\n";
for (int i = 0; i < n; i++) {
cout << (-1) * v[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
if (b == 1) return a;
long long int r = power(a, b / 2) % 1000000007;
if (b % 2 == 0)
return (r * r) % 1000000007;
else
return (((r * r) % 1000000007) * a) % 1000000007;
}
int prime[1000009];
int sumprime[1000009];
void sieve(int n) {
prime[0] = prime[1] = 1;
for (int i = 2; i <= sqrt(n); i++) {
if (!prime[i]) {
for (int j = 2 * i; j <= n; j = j + i) {
prime[j]++;
}
}
}
for (int i = 1; i <= n; i++) {
if (!prime[i]) {
sumprime[i] = sumprime[i - 1] + 1;
} else {
sumprime[i] = sumprime[i - 1];
}
}
}
bool comp(const pair<long long int, long long int> &a,
const pair<long long int, long long int> &b) {
return (a.second < b.second);
}
const int N = 5 * 1e5 + 9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
t = 1;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << "1 1\n0\n";
cout << "1 1\n0\n";
cout << "1 1\n" << -a[0] << "\n";
continue;
}
if (n == 2) {
cout << "1 1\n" << -a[0] << "\n";
cout << "2 2\n" << -a[1] << "\n";
cout << "1 1\n0\n";
continue;
}
if (n == 3) {
cout << "1 1\n" << -a[0] << "\n";
cout << "2 2\n" << -a[1] << "\n";
cout << "3 3\n" << -a[2] << "\n";
continue;
}
cout << "1 " << n << "\n";
for (int i = 0; i < n - 1; i++) {
long long int val = a[i] * n;
a[i] = a[i] - val;
val = -1 * val;
cout << val << " ";
}
cout << 0 << " ";
cout << "\n";
cout << "1 " << n - 1 << "\n";
for (int i = 0; i < n - 1; i++) {
a[i] = -a[i];
cout << a[i] << " ";
}
cout << "\n";
cout << n << " " << n << "\n" << -a[n - 1] << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long powermodm(long long x, long long n, long long M) {
long long result = 1;
while (n > 0) {
if (n % 2 == 1) result = (result * x) % M;
x = (x * x) % M;
n = n / 2;
}
return result;
}
bool contains(long long *arr, long long x, long long n) {
for (long long i = 0; i < n; i++) {
if (arr[i] == x) {
return true;
}
}
return false;
}
int gcd(int a, int b) {
if (b == 0) return a;
a %= b;
return gcd(b, a);
}
long long power1(long long x, long long n) {
long long res = 1;
while (n > 0) {
if (n % 2) {
res = res * x;
}
x = x * x;
n /= 2;
}
return res;
}
class SegmentTree {
long long *tree;
public:
SegmentTree(long long *A, long long n) { build(0, 0, n - 1, A); }
void build(long long node, long long start, long long end, long long *A) {
if (start == end) {
tree[node] = A[start];
} else {
long long mid = (start + end) / 2;
build(2 * node + 1, start, mid, A);
build(2 * node + 2, mid + 1, end, A);
tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
}
}
void update(long long node, long long start, long long end, long long idx,
long long val, long long *A) {
if (start == end) {
A[idx] = val;
tree[node] = val;
} else {
long long mid = (start + end) / 2;
if (start <= idx and idx <= mid) {
update(2 * node + 1, start, mid, idx, val, A);
} else {
update(2 * node + 2, mid + 1, end, idx, val, A);
}
tree[node] = tree[2 * node + 1] + tree[2 * node + 2];
}
}
long long query(long long node, long long start, long long end, long long l,
long long r) {
if (r < start or end < l) {
return 0;
}
if (l <= start and end <= r) {
return tree[node];
}
long long mid = (start + end) / 2;
long long p1 = query(2 * node + 1, start, mid, l, r);
long long p2 = query(2 * node + 2, mid + 1, end, l, r);
return p1 + p2;
}
};
class TrieNode {
public:
TrieNode *adj[2];
long long height;
TrieNode() {
for (long long i = 0; i < 2; i++) {
adj[i] = NULL;
}
height = 0;
}
};
void insert(TrieNode *root, long long n) {
TrieNode *tmp = root;
for (long long i = 29; i >= 0; i--) {
long long pos = ((n & (1LL << i)) != 0 ? 1 : 0);
if (tmp->adj[pos] == NULL) {
tmp->adj[pos] = new TrieNode();
}
tmp = tmp->adj[pos];
}
}
long long findShort(long long *pre, long long i, long long n, long long x) {
long long low = 1, high = i, mid;
long long ans = high;
while (low <= high) {
mid = (low + high) / 2;
if (pre[i] - pre[mid - 1] <= x) {
ans = min(ans, mid);
high = mid - 1;
} else {
low = mid + 1;
}
}
return ans;
}
bool sorted(vector<long long> arr) {
if (arr.size() == 1) {
return true;
}
for (long long i = 1; i < arr.size(); i++) {
if (arr[i] < arr[i - 1]) {
return false;
}
}
return true;
}
bool custSort(pair<long long, long long> a, pair<long long, long long> b) {
return (a.first > b.first || (a.first == b.first && a.second > b.second));
}
long long getAns(long long *arr, long long n, long long c) {
long long ans = 0;
for (long long i = 0; i < n; i++) {
ans += abs(arr[i] - power1(c, i));
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
cout << 1 << " " << 1 << '\n';
cout << -a[0] << '\n';
} else {
cout << 1 << " " << 1 << '\n';
cout << -a[0] << '\n';
cout << 1 << " " << n << '\n';
for (long long i = 0; i < n; i++) {
if (i == 0) {
cout << 0 << ' ';
} else {
cout << -n * a[i] << ' ';
}
}
cout << '\n';
cout << 2 << " " << n << '\n';
for (long long i = 1; i < n; i++) {
cout << (n - 1) * a[i] << " ";
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
return a * b / gcd(a, b);
}
const int N = 1e5 + 10;
int a[N], n;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
if (n == 1) {
puts("1 1\n0\n1 1\n0\n1 1");
printf("%d\n", -a[1]);
return 0;
}
printf("%d %d\n", 1, n);
for (int i = 1; i <= n; i++)
printf("%lld%c", -a[i] * 1ll * n, (i == n) ? '\n' : ' ');
printf("%d %d\n", 1, n - 1);
for (int i = 1; i <= n - 1; i++)
printf("%lld%c", a[i] * 1ll * (n - 1), (i == n - 1) ? '\n' : ' ');
printf("%d %d\n", n, n);
printf("%lld\n", a[n] * 1ll * (n - 1));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 100;
const int MOD = 1000000007;
const double eps = 1e-8;
const double PI = acos(-1.0);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n, long long p = MOD) {
long long r = 1 % p;
for (a %= p; n; a = a * a % p, n >>= 1)
if (n & 1) r = r * a % p;
return r;
}
long long inv(long long x, long long p = MOD) {
return x <= 1 ? 1 : inv(p % x, p) * (p - p / x) % p;
}
long long a[100005];
long long add[100005];
void solve() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
}
if (n == 1) {
printf("1 1\n%lld\n1 1\n0\n1 1\n0\n", -a[1]);
return;
}
if (n == 2) {
printf("1 1\n%lld\n2 2\n%lld\n1 1\n0\n", -a[1], -a[2]);
return;
}
printf("1 1\n%lld\n", -a[1]);
for (int i = 2; i <= n; i++) {
add[i] = a[i] * (n - 1);
}
printf("2 %d\n", n);
for (int i = 2; i <= n; i++) {
printf("%lld%c", add[i], i == n ? '\n' : ' ');
}
printf("1 %d\n", n);
for (int i = 1; i <= n; i++) {
printf("%lld%c", i == 1 ? 0 : -(add[i] + a[i]), i == n ? '\n' : ' ');
}
}
int main(int argc, char* argv[]) {
int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long int arr[maxn];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> arr[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << -arr[0] << endl;
return 0;
}
cout << "1 1" << endl;
cout << -arr[0] << endl;
arr[0] = 0;
cout << "2 " << n << endl;
for (int i = 1; i < n; ++i) {
cout << arr[i] * (n - 1) << " ";
arr[i] += (arr[i] * (n - 1));
}
cout << endl;
cout << "1 " << n << endl;
for (int i = 0; i < n; ++i) {
cout << -arr[i] << " ";
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
long long int gcd(long long int a, long long int b) {
if (a < b)
return gcd(b, a);
else if (b == 0)
return a;
else
return gcd(b, a % b);
}
long long int isPrime(long long int n) {
long long int p = (long long int)sqrt(n);
for (int i = (2); i <= (p); i += (1))
if (n % i == 0) return 0;
return 1;
}
long long int pow(long long int b, long long int e) {
if (e == 0)
return 1;
else if (e % 2 == 0) {
long long int a = pow(b, e / 2);
return a * a;
} else {
long long int a = pow(b, e / 2);
return b * a * a;
}
}
long long int powm(long long int x, long long int y,
long long int m = 1000000007) {
x = x % m;
long long int res = 1;
while (y) {
if (y & 1) res = res * x;
res %= m;
y = y >> 1;
x = x * x;
x %= m;
}
return res;
}
long long int modInverse(long long int a, long long int m) {
return powm(a, m - 2, m);
}
void solve() {
long long int n;
cin >> n;
vector<long long int> arr(n);
for (int i = (0); i <= (n - 1); i += (1)) cin >> arr[i];
if (n == 1) {
cout << "1 1" << '\n'
<< (-arr[0]) << '\n'
<< "1 1"
<< "\n0" << '\n'
<< "1 1\n"
<< "0" << '\n';
return;
}
vector<vector<long long int>> ans;
ans.push_back({1, 1, -arr[0]});
arr[0] = 0;
vector<long long int> temp;
temp.push_back(2);
temp.push_back(n);
for (int i = (1); i <= (n - 1); i += (1)) {
long long int x = arr[i] % n;
arr[i] += x * (n - 1);
temp.push_back(x * (n - 1));
}
ans.push_back(temp);
temp.clear();
temp.push_back(1);
temp.push_back(n);
for (int i = (0); i <= (n - 1); i += (1)) {
temp.push_back(-arr[i]);
}
ans.push_back(temp);
for (int i = (0); i <= (2); i += (1)) {
cout << ans[i][0] << " " << ans[i][1] << '\n';
for (int j = (2); j <= ((int)ans[i].size() - 1); j += (1))
cout << ans[i][j] << " ";
cout << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
int T = 1;
while (T--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (a > b) swap(a, b);
if (a == 0) return b;
return gcd(b % a, a);
}
unsigned long long binpow(long long a, long long b) {
if (b == 0) return 1;
long long res = binpow(a, b / 2) % 1000000007;
if (b % 2)
return ((unsigned long long)res * (unsigned long long)res *
(unsigned long long)a) %
1000000007;
else
return ((unsigned long long)res * (unsigned long long)res) % 1000000007;
}
int main() {
int T = 1;
while (T--) {
int n;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << "1 1"
<< "\n";
cout << -a[0] << "\n";
cout << "1 1"
<< "\n";
cout << a[0] << "\n";
cout << "1 1"
<< "\n";
cout << -a[0] << "\n";
continue;
}
cout << "1 " << n << "\n";
for (int i = 0; i < n; i++) {
long long t = 0;
t -= n * a[i];
a[i] -= n * a[i];
cout << t << " ";
}
cout << "\n";
cout << "1 " << n - 1 << "\n";
for (int i = 0; i < n - 1; i++) {
cout << 0 - a[i] << " ";
}
cout << "\n";
cout << n << " " << n << "\n";
cout << 0 - a[n - 1];
}
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
long long int MulMod(long long int a, long long int b) { return (a * b) % MOD; }
long long int AddMod(long long int a, long long int b) { return (a + b) % MOD; }
const long long int MAXN = 1e5 + 10;
long long int a[MAXN];
void solving() {
long long int n;
cin >> n;
for (long long int i = (1); i <= (n); i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
} else {
cout << 1 << " " << 1 << '\n';
for (long long int i = (1); i <= (1); i++) cout << a[i] * (n - 1) << " ";
cout << '\n';
for (long long int i = (1); i <= (1); i++) a[i] = a[i] + (n - 1) * a[i];
cout << 2 << " " << n << '\n';
for (long long int i = (2); i <= (n); i++) cout << a[i] * (n - 1) << " ";
cout << '\n';
for (long long int i = (2); i <= (n); i++) a[i] = a[i] + (n - 1) * a[i];
cout << 1 << " " << n << '\n';
for (long long int i = (1); i <= (n); i++) cout << -a[i] << " ";
cout << '\n';
for (long long int i = (1); i <= (n); i++) assert(a[i] % n == 0);
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int t = 1;
for (long long int i = (1); i <= (t); i++) {
solving();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mx = 1e5 + 9, INF = 1e18, M = 1e6;
long long N, A[mx];
void open() {
if (fopen("aa.inp", "r")) {
freopen("aa.inp", "r", stdin);
freopen("aa.out", "w", stdout);
}
}
void solve() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
for (long long i = 1; i <= N; ++i) {
cin >> A[i];
}
if (N == 1) {
cout << "1 1"
<< "\n";
cout << -A[1] << "\n";
cout << "1 1"
<< "\n";
cout << 0 << "\n";
cout << "1 1"
<< "\n";
cout << 0 << "\n";
return;
}
if (N == 2) {
cout << "1 1"
<< "\n";
cout << -A[1] << "\n";
cout << "2 2"
<< "\n";
cout << -A[2] << "\n";
cout << "1 1"
<< "\n";
cout << 0 << "\n";
return;
}
cout << N << " " << N << "\n" << -A[N] << "\n";
cout << 1 << " " << N - 1 << "\n";
for (long long i = 1; i < N; ++i) {
long long a = A[i] % N * (N - 1);
if (A[i] < 0)
a = -abs(a);
else
a = abs(a);
cout << a << " ";
A[i] += a;
}
cout << "\n";
cout << 1 << " " << N << "\n";
for (long long i = 1; i < N; ++i) {
cout << -A[i] << " ";
}
cout << 0;
}
int main() {
open();
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
if (a == 0) {
*x = 0;
*y = 1;
return b;
}
long long x1, y1;
long long gcd = gcdExtended(b % a, a, &x1, &y1);
*x = y1 - (b / a) * x1;
*y = x1;
return gcd;
}
void diophantine(long long a, long long b, long long c, long long *c1,
long long *c2) {
long long x, y;
long long d = gcdExtended(a, b, &x, &y);
c = c / d;
*c1 = x * c;
*c2 = y * c;
}
int main() {
long long n;
cin >> n;
long long aa[n], bb[n], cc[n];
for (long long i = 0; i <= n - 1; i++) cin >> aa[i];
if (n == 1) {
cout << 1 << " " << 1 << endl;
cout << -1 * aa[0] << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
cout << 1 << " " << 1 << endl;
cout << 0 << endl;
return 0;
}
for (int i = 0; i < n; i++) {
long long x, y;
diophantine(n, n - 1, aa[i] * -1, &x, &y);
bb[i] = x * n;
cc[i] = y * (n - 1);
if (i == n - 1) {
diophantine(n, 1, aa[i] * -1, &x, &y);
bb[i] = x * n;
cc[i] = y;
}
}
cout << 1 << " " << n << endl;
for (long long i = 0; i <= n - 1; i++) cout << bb[i] << " ";
cout << endl;
cout << 1 << " " << n - 1 << endl;
for (long long i = 0; i <= n - 2; i++) cout << cc[i] << " ";
cout << endl;
cout << n << " " << n << endl;
cout << cc[n - 1] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int a[N];
long long ans[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
if (n == 1) {
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << 0 << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << -a[1] << '\n';
return 0;
}
for (int i = 1; i <= n; i++) {
long long x = a[i];
long long yu = x % (n - 1);
long long byu = 0;
if (yu) byu = (n - 1 - yu) * n;
ans[i] = byu + a[i];
}
cout << 1 << ' ' << n << '\n';
for (int i = 1; i <= n; i++) {
cout << ans[i] - a[i] << ' ';
}
cout << '\n';
cout << 1 << ' ' << 1 << '\n';
cout << -ans[1] << '\n';
cout << 2 << ' ' << n << '\n';
for (int i = 2; i <= n; i++) {
cout << -ans[i] << ' ';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long t, n, a[maxn], b[maxn];
signed main() {
cin >> n;
for (long long i = 1; i <= n; i++) cin >> a[i];
if (n == 1) {
cout << 1 << " " << 1 << '\n';
cout << -a[1] << '\n';
for (long long i = 2; i <= 3; i++) {
cout << 1 << " " << 1 << '\n';
cout << 0 << '\n';
}
return 0;
}
cout << 1 << " " << n - 1 << "\n";
for (long long i = 1; i <= n - 1; i++) {
cout << (n - 1) * a[i] << " ";
a[i] += (n - 1) * a[i];
}
cout << endl;
cout << n << " " << n << '\n';
cout << -a[n] << '\n';
cout << 1 << " " << n << '\n';
for (long long i = 1; i < n; i++) cout << -a[i] << " ";
cout << 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int msb(long long x) {
union {
double a;
int32_t b[2];
};
a = x;
return (b[1] >> 20) - 1023;
}
long long po(int a, int b) {
long long c = 1;
while (b) {
if (a > (long long)1e9 && b > 1) return 0;
if (b % 2) c *= a;
a *= a;
b /= 2;
}
return c;
}
void sol() {
long long n;
cin >> n;
vector<long long> a(n);
for (int i = (0); i < (n); i++) {
cin >> a[i];
}
if (n == 1) {
cout << "1 1\n";
cout << -a[0];
cout << "\n1 1\n0\n1 1\n0";
return;
}
cout << "1 " << n << "\n";
for (int i = (0); i < (n); i++) cout << -a[i] * n << " ";
cout << "\n1 " << n - 1 << "\n";
for (int i = (0); i < (n - 1); i++) cout << a[i] * (n - 1) << " ";
cout << "\n" << n << " " << n << "\n" << a[n - 1] * (n - 1);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--) sol();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t = 1;
while (t--) {
long long n;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) cin >> a[i];
if (n == 1) {
cout << "1 1" << endl;
cout << "0" << endl;
cout << "1 1" << endl;
cout << 0 << endl;
cout << "1 1" << endl;
cout << -a[0] << endl;
} else {
cout << "1 1" << endl;
cout << -a[0] << endl;
cout << "2"
<< " " << n << endl;
for (int i = 1; i < n; i++) {
cout << a[i] * (n - 1) << " ";
}
cout << endl;
cout << "1"
<< " " << n << endl;
cout << "0 ";
for (int i = 1; i < n; i++) cout << -a[i] * n << " ";
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.