#include <bits/stdc++.h> typedef long long ll; using namespace std; struct rank_change { ll v; ll pos; }; int n; ll v; ll tab[303][303]; ll pref[303]; int main() { scanf("%d", &n); for(int i = 1; i<=n; i++) { scanf("%lld", &v); for(int j = 1; j<=i-1; j++) { tab[i][j] = tab[i-1][j]; pref[i] += tab[i][j]; } tab[i][i] = v-pref[i-1]; pref[0] = 100000000000; pref[i] += tab[i][i]; if(pref[i] - tab[1][1] > pref[i-1]) { printf("NIE"); return 0; } } printf("TAK\n%d\n", (n*(n+1))/2 + n); for(int i = 1; i<=n; i++) { for(int j = 1; j<=i; j++) { printf("%lld ", tab[i][j]); } printf("-100000000000 "); } 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 | #include <bits/stdc++.h> typedef long long ll; using namespace std; struct rank_change { ll v; ll pos; }; int n; ll v; ll tab[303][303]; ll pref[303]; int main() { scanf("%d", &n); for(int i = 1; i<=n; i++) { scanf("%lld", &v); for(int j = 1; j<=i-1; j++) { tab[i][j] = tab[i-1][j]; pref[i] += tab[i][j]; } tab[i][i] = v-pref[i-1]; pref[0] = 100000000000; pref[i] += tab[i][i]; if(pref[i] - tab[1][1] > pref[i-1]) { printf("NIE"); return 0; } } printf("TAK\n%d\n", (n*(n+1))/2 + n); for(int i = 1; i<=n; i++) { for(int j = 1; j<=i; j++) { printf("%lld ", tab[i][j]); } printf("-100000000000 "); } return 0; } |