#include<bits/stdc++.h> using namespace std; int n; long long a, mn,sum, mx; vector<long long> odp; int main() { scanf("%d", &n); if(n == 1) { scanf("%lld", &a); printf("TAK\n1\n%lld", a); } scanf("%lld", &mn); odp.push_back(mn); sum+=mn; for(int i = 1; i < n; ++i) { scanf("%lld", &a); if(a%(i+1) == 0) mx = a/(i+1); else { mx = 1+(a/(i+1)); } if(mx > mn) { printf("NIE"); return 0; } odp.push_back(a-sum); sum = a; mn = mx; } printf("TAK\n%lu\n", odp.size()); for(int i = 0; i < n; ++i) printf("%lld ", odp[i]); }
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 | #include<bits/stdc++.h> using namespace std; int n; long long a, mn,sum, mx; vector<long long> odp; int main() { scanf("%d", &n); if(n == 1) { scanf("%lld", &a); printf("TAK\n1\n%lld", a); } scanf("%lld", &mn); odp.push_back(mn); sum+=mn; for(int i = 1; i < n; ++i) { scanf("%lld", &a); if(a%(i+1) == 0) mx = a/(i+1); else { mx = 1+(a/(i+1)); } if(mx > mn) { printf("NIE"); return 0; } odp.push_back(a-sum); sum = a; mn = mx; } printf("TAK\n%lu\n", odp.size()); for(int i = 0; i < n; ++i) printf("%lld ", odp[i]); } |