Submission #229368

# Submission time Handle Problem Language Result Execution time Memory
229368 2020-05-04T10:32:45 Z VEGAnn Popcount (COCI19_popcount) C++14
0 / 110
6 ms 640 KB
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
const int N = 510;
vector<int> pows[N], fi, se;
int n, k;

void sum(vector<int> &a, vector<int> b){
    for (int i = 0, ost = 0; i < max(sz(a), sz(b)) || ost; i++){
        if (i == sz(a)) a.PB(0);

        int csum = ost + a[i] + (i < sz(b) ? b[i] : 0);

        ost = bool(csum > 9);

        if (csum > 9) csum -= 10;

        a[i] = csum;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> k;

    pows[0].clear();
    pows[0].PB(1);

    for (int i = 1; i < n; i++) {
        pows[i] = pows[i - 1];
        sum(pows[i], pows[i - 1]);
    }

    for (int len = 2; ; len += len){
        cout << "A=((A&";

        fi.clear();
        se.clear();

        fi.PB(0);
        se.PB(0);

        int half_len = (len >> 1);

        for (int i = 0; i < n; i++)
            if (i % len < half_len)
                sum(fi, pows[i]);
            else sum(se, pows[i]);

        for (int it = sz(fi) - 1; it >= 0; it--)
            cout << fi[it];

        cout << ")+((A&";

        for (int it = sz(se) - 1; it >= 0; it--)
            cout << se[it];

        cout << ")>>" << half_len << "))\n";

        if (len >= n) break;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 640 KB Wrong output format.
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 416 KB Wrong output format.
2 Halted 0 ms 0 KB -