File size: 513 Bytes
1fd0050 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream>
using namespace std;
int main() {
int k;
cin >> k;
int c = (k - 1) / 2;
int n = k; // because k = 2c + 1
cout << n << "\n";
for (int i = 1; i <= c; ++i) {
int next = i + 1;
if (i == c) next = c + 1;
cout << "POP 2 GOTO " << c + 1 << " PUSH 1 GOTO " << next << "\n";
}
for (int i = c + 1; i <= 2 * c; ++i) {
cout << "POP 1 GOTO " << i + 1 << " PUSH 2 GOTO " << i << "\n";
}
cout << "HALT PUSH 1 GOTO 1\n";
return 0;
} |