#include <stdio.h> int a[301]; int b[1000]; int n; int wklesly(void) { int x,y,f; f=1; for(x=1;x<=n;++x) for(y=1;y<=n;++y) if(x+y<=n) { if(a[x+y]>a[x]+a[y]) f=0; } return f; } int main() { int i,b; scanf("%d",&n); for(i=1;i<=n;++i) scanf("%d",&(a[i])); if(wklesly()) {printf("TAK\n"); printf("%d\n",n); printf("%d",a[1]); b=a[1]; for(i=2;i<=n;++i) {printf(" %d",a[i]-b); b=b+(a[i]-b);}} else printf("NIE\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 31 32 33 34 35 36 | #include <stdio.h> int a[301]; int b[1000]; int n; int wklesly(void) { int x,y,f; f=1; for(x=1;x<=n;++x) for(y=1;y<=n;++y) if(x+y<=n) { if(a[x+y]>a[x]+a[y]) f=0; } return f; } int main() { int i,b; scanf("%d",&n); for(i=1;i<=n;++i) scanf("%d",&(a[i])); if(wklesly()) {printf("TAK\n"); printf("%d\n",n); printf("%d",a[1]); b=a[1]; for(i=2;i<=n;++i) {printf(" %d",a[i]-b); b=b+(a[i]-b);}} else printf("NIE\n"); return 0; } |