#include<bits/stdc++.h> #define lim 100009 using namespace std; int n; int tab[lim]; int main() { scanf("%d", &n); for(int i = 1;i<=n;++i) { scanf("%d", &tab[i]); } for(int i = n-1;i>0;--i) { int j = i+1; if(tab[i]<tab[j]-tab[j]/j) { printf("NIE\n"); return 0; } } printf("TAK\n%d\n", (n+2)*(n+1)/2-1); for(int i = 1;i<=n;++i) { int a = tab[i]/i; int m = abs(tab[i]-a*i); int sgn = 1; if(tab[i]<0) sgn = -1; for(int j = 1;j<=m;++j) { printf("%d ", a+sgn); } for(int j = m+1;j<=i;++j) { printf("%d ", a); } printf("-10000000000000 "); } }
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 | #include<bits/stdc++.h> #define lim 100009 using namespace std; int n; int tab[lim]; int main() { scanf("%d", &n); for(int i = 1;i<=n;++i) { scanf("%d", &tab[i]); } for(int i = n-1;i>0;--i) { int j = i+1; if(tab[i]<tab[j]-tab[j]/j) { printf("NIE\n"); return 0; } } printf("TAK\n%d\n", (n+2)*(n+1)/2-1); for(int i = 1;i<=n;++i) { int a = tab[i]/i; int m = abs(tab[i]-a*i); int sgn = 1; if(tab[i]<0) sgn = -1; for(int j = 1;j<=m;++j) { printf("%d ", a+sgn); } for(int j = m+1;j<=i;++j) { printf("%d ", a); } printf("-10000000000000 "); } } |