#include <bits/stdc++.h> #define ll long long int main() { std::ios::sync_with_stdio(false); using namespace std; ll n; cin >> n; vector<ll> A(n), B(n + 1, 0); for(ll i = 0; i < n; i++) cin >> A[i]; B[0] = 0; B[1] = A[0]; bool good = true; for(ll i = 1; i < n; i++) { if(A[i - 1] * (i + 1) < A[i] * i) good = false; B[i + 1] = A[i] - A[i - 1]; } if(!good) cout << "NIE\n"; else { cout << "TAK\n" << n << "\n"; for(ll i = 0; i < n; i++) cout << B[i + 1] << " "; cout << "\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 | #include <bits/stdc++.h> #define ll long long int main() { std::ios::sync_with_stdio(false); using namespace std; ll n; cin >> n; vector<ll> A(n), B(n + 1, 0); for(ll i = 0; i < n; i++) cin >> A[i]; B[0] = 0; B[1] = A[0]; bool good = true; for(ll i = 1; i < n; i++) { if(A[i - 1] * (i + 1) < A[i] * i) good = false; B[i + 1] = A[i] - A[i - 1]; } if(!good) cout << "NIE\n"; else { cout << "TAK\n" << n << "\n"; for(ll i = 0; i < n; i++) cout << B[i + 1] << " "; cout << "\n"; } return 0; } |