#include <iostream> using namespace std; int tab[301]; int wyn[301]; int main(int argc, char* argv[]) { ios_base::sync_with_stdio (false); int n, i, j, s; cin >> n; for (i = 1; i <= n; ++i) { cin >> tab[i]; wyn[i] = tab[i]-tab[i-1]; s=0; for(j = 1; j < i; ++j) { s+=wyn[i-j+1]; if(s>tab[j]) { goto err; } } } cout << "TAK\n" << n << "\n"; for (i = 1; i < n; ++i) { cout << wyn[i] << " "; } cout<<wyn[n]<<"\n"; return 0; err: cout << "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 | #include <iostream> using namespace std; int tab[301]; int wyn[301]; int main(int argc, char* argv[]) { ios_base::sync_with_stdio (false); int n, i, j, s; cin >> n; for (i = 1; i <= n; ++i) { cin >> tab[i]; wyn[i] = tab[i]-tab[i-1]; s=0; for(j = 1; j < i; ++j) { s+=wyn[i-j+1]; if(s>tab[j]) { goto err; } } } cout << "TAK\n" << n << "\n"; for (i = 1; i < n; ++i) { cout << wyn[i] << " "; } cout<<wyn[n]<<"\n"; return 0; err: cout << "NIE\n"; return 0; } |