Submission details
Task:Ohjelmat
Sender:Kuha
Submission time:2025-10-18 13:08:25 +0300
Language:text (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttimescore
#10.00 s0details

Code

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int t;
    cin>>t;
    while (t --> 0) {
        int x;
        cin>>x;
        vector<int> v = {0};
        vector<string> out;
        while (1<<(v.back() + 1) <= x) {
            if (x & (1<<v.back())) {
                out.push_back("DUP");
                out.push_back("DUP");
                out.push_back("+");
                v.push_back(v.back() + 1);
            } else {    
                out.push_back("DUP");
                out.push_back("+");
                v.back()++;
            }
        }
        while (v.size() != 1) {
            out.push_back("+");
            v.pop_back();
        }
        cout<<out.size()<<endl;
        for (string s : out) cout<<s<<" ";
        cout<<endl;
    }
}

Test details

Test 1

Verdict:

input
100
156798
300372
911450
236249
...

correct output
21
20
23
22
24
...

user output
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
...