#include <bits/stdc++.h> using namespace std; const long long inf = -1e13; int n; int a[307]; bool ok() { for (int j = 1; j < n; j++) { for (int i = 0; i < j; i++) { if ((long long)a[i] < ((long long)i * (long long)a[j] - 1) / (long long)j + 1) { return 0; } } } return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } if (ok()) { cout << "TAK\n" << (long long)n * (long long)(n + 1) / 2 + (long long)n << "\n"; for (int i = 0; i < n; i++) { int co, wi; if (a[i] >= 0) { co = a[i] / (i + 1); wi = a[i] - co * (i + 1); for (int j = 0; j < wi; j++) cout << co + 1 << " "; for (int j = wi; j <= i; j++) cout << co << " "; } else { co = -a[i] / (i + 1); wi = -a[i] - co * (i + 1); co *= -1; for (int j = 0; j < wi; j++) cout << co - 1 << " "; for (int j = wi; j <= i; j++) cout << co << " "; } cout << inf << " "; } } else { cout << "NIE\n"; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <bits/stdc++.h> using namespace std; const long long inf = -1e13; int n; int a[307]; bool ok() { for (int j = 1; j < n; j++) { for (int i = 0; i < j; i++) { if ((long long)a[i] < ((long long)i * (long long)a[j] - 1) / (long long)j + 1) { return 0; } } } return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } if (ok()) { cout << "TAK\n" << (long long)n * (long long)(n + 1) / 2 + (long long)n << "\n"; for (int i = 0; i < n; i++) { int co, wi; if (a[i] >= 0) { co = a[i] / (i + 1); wi = a[i] - co * (i + 1); for (int j = 0; j < wi; j++) cout << co + 1 << " "; for (int j = wi; j <= i; j++) cout << co << " "; } else { co = -a[i] / (i + 1); wi = -a[i] - co * (i + 1); co *= -1; for (int j = 0; j < wi; j++) cout << co - 1 << " "; for (int j = wi; j <= i; j++) cout << co << " "; } cout << inf << " "; } } else { cout << "NIE\n"; } return 0; } |