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
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 1234567890;

int main(int argc, char** argv) {
  int n;
  int a[345];
  int b[345];
  int c[345];
  scanf("%d", &n);
  for(int i=0;i<n;i++) {
    scanf("%d",&(a[i]));
  }

  b[0] = a[0];
  for(int i=1;i<n;i++) {
    b[i] = a[i] - a[i-1];
  }

  for(int len=1;len<=n;len++) {
    int ma = -INF;
    for(int i=0;i<=n-len;i++) {
      int s = 0;
      for(int j=0;j<len;j++) {
        s += b[i+j];
      }
      ma = max(ma, s);
    }
    c[len-1] = ma;
  }

  if(equal(a, a + n, c)) {
    printf("TAK\n");
    printf("%d\n", n);
    for(int i=0;i<n;i++) {
      if(i > 0) {
        printf(" ");
      }
      printf("%d", b[i]);
    }
    printf("\n");
  } else {
    printf("NIE\n");
  }
  return 0;
}