Submission #199761

#TimeUsernameProblemLanguageResultExecution timeMemory
199761SamAndPopcount (COCI19_popcount)C++17
0 / 110
6 ms504 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...