| Task: | Program |
| Sender: | aalto25e_001 |
| Submission time: | 2025-10-01 16:59:23 +0300 |
| Language: | C++ (C++11) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:15:3: error: 'vector' was not declared in this scope
15 | vector<string> op;
| ^~~~~~
input/code.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
1 | #include <iostream>
+++ |+#include <vector>
2 |
input/code.cpp:15:16: error: expected primary-expression before '>' token
15 | vector<string> op;
| ^
input/code.cpp:15:18: error: 'op' was not declared in this scope
15 | vector<string> op;
| ^~
input/code.cpp:26:3: error: 'reverse' was not declared in this scope
26 | reverse(op.begin(), op.end());
| ^~~~~~~Code
#include <iostream>
using namespace std;
long long n;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
if (n % 3 == 0) {
cout << 0 << '\n';
return 0;
}
vector<string> op;
op.emplace_back("END");
while (n > 1) {
if (n % 2 == 0) {
op.emplace_back("MUL");
n /= 2;
} else {
n -= 3;
op.emplace_back("ADD");
}
}
reverse(op.begin(), op.end());
cout << op.size() << '\n';
for (auto x : op) {
cout << x << '\n';
}
return 0;
}
