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
51
52
53
54
55
#include<bits/stdc++.h>
using namespace std;

long long sums[309];
vector<long long> v;
const long long M = -1e13;

int main()
{
    long long n, a, b, c, d, e, f, st = 0, ab = 0, tr = 1;
    scanf("%lld", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld", &a);
        sums[i] = a;
        if(a < 0) ab = 1;
        b = a / i;
        c = a - b * i;
        c = abs(c);
        if(c > 1) d = (i - c) / (c - 1);
        else d = i + 2;
        e = d;
        f = 0;
        for(int j=1; j<=i; j++)
        {
            if((e == d && f < c) || (j == i && f < c))
            {
                e = 0;
                f++;
                if(ab == 0) v.push_back(b+1);
                else v.push_back(b-1);
            }
            else
            {
                e++;
                v.push_back(b);
            }
        }
        b = 0;
        for(int j=0; j<i; j++) 
        {
            b += v[st + j];
            if(b > sums[j + 1]) tr = 0;
        }
        v.push_back(M);
        st = v.size();
    }
    if(tr == 0) printf("NIE");
    else
    {
        printf("TAK\n%d\n", v.size());
        for(int i=0; i<v.size(); i++) printf("%lld ", v[i]);
    }
    return 0;
}