#include <stdio.h> #include <stdlib.h> using namespace std; int main() { int n; scanf("%d", &n); int *a = new int[n](); for(int i=0; i<n; i++) { scanf("%d", a+i); if(a[i] > a[i-1] + a[0]) { printf("NIE"); return 0; } } unsigned long long k = n*n; printf("TAK\n%llu\n", k); int curr, last, part; for(int i=0; i<n; i++) { curr = a[i]; if(curr % (i+1) == 0) { last = part = curr / (i+1); } else { part = curr / i; last = curr % i; } for(int j=0;j<i;j++) { printf("%d ", part); } printf("%d ", last); for(int j=i+1;j<n;j++) { printf("-1000001 "); } } delete [] a; 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 | #include <stdio.h> #include <stdlib.h> using namespace std; int main() { int n; scanf("%d", &n); int *a = new int[n](); for(int i=0; i<n; i++) { scanf("%d", a+i); if(a[i] > a[i-1] + a[0]) { printf("NIE"); return 0; } } unsigned long long k = n*n; printf("TAK\n%llu\n", k); int curr, last, part; for(int i=0; i<n; i++) { curr = a[i]; if(curr % (i+1) == 0) { last = part = curr / (i+1); } else { part = curr / i; last = curr % i; } for(int j=0;j<i;j++) { printf("%d ", part); } printf("%d ", last); for(int j=i+1;j<n;j++) { printf("-1000001 "); } } delete [] a; return 0; } |