Submission #199761

# Submission time Handle Problem Language Result Execution time Memory
199761 2020-02-03T08:09:27 Z SamAnd Popcount (COCI19_popcount) C++17
0 / 110
6 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

int n, k;

vector<int> ang2(const vector<int>& v)
{
    vector<int> ans;
    int m = 0;
    for (int i = v.size() - 1; i >= 0; --i)
    {
        ans.push_back((v[i] * 2 + m) % 10);
        m = (v[i] * 2 + m) / 10;
    }
    if (m)
        ans.push_back(m);
    reverse(ans.begin(), ans.end());
    return ans;
}

void tp(const vector<int>& v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        cout << v[i];
    }
}

void solv1()
{
    vector<int> v;
    v.push_back(1);
    for (int i = 1; i <= k; ++i)
    {
        v = ang2(v);
        cout << "A=(A-(A&";
        tp(v);
        cout << "))+((A&";
        tp(v);
        cout << ")>>" << i << ")\n";
    }
}

int main()
{
    cin >> n >> k;
    if (2 <= n && n <= 100 && k == n - 1)
        solv1();
    return 0;
}

Compilation message

popcount.cpp: In function 'void tp(const std::vector<int>&)':
popcount.cpp:23:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); ++i)
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 504 KB Wrong output format.
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Wrong output format.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Wrong output format.
2 Halted 0 ms 0 KB -