# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648259 | kingfran1907 | Popcount (COCI19_popcount) | C++14 | 5 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 510;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;
int n, k;
vector< string > sol;
string pot[maxn];
string add(string a, string b) {
while (a.size() < b.size()) a.push_back('0');
while (b.size() < a.size()) b.push_back('0');
int car = 0;
string out;
for (int i = 0; i < a.size(); i++) {
int tren = (int)a[i] + b[i] - 2 * '0' + car;
out.push_back((tren % 10) + '0');
car = tren / 10;
}
if (car > 0) out.push_back(car + '0');
while (out.back() == '0') out.pop_back();
return out;
}
string conv(int x) {
if (x == 0) return "0";
string out;
while (x > 0) {
out.push_back((x % 10) + '0');
x /= 10;
}
reverse(out.begin(), out.end());
return out;
}
int main() {
scanf("%d%d", &n, &k);
pot[0] = "1";
for (int i = 1; i < n; i++)
pot[i] = add(pot[i - 1], pot[i - 1]);
for (int i = 1; i < n; i *= 2) {
string num = "0";
string comp = "0";
for (int j = 0; j < n; j++) {
if (j & i) num = add(num, pot[j]);
else comp = add(comp, pot[j]);
}
reverse(num.begin(), num.end());
reverse(comp.begin(), comp.end());
string tren = "A=((A&" + comp + ")+((A&" + num + ")>>" + conv(i) + "))";
sol.push_back(tren);
}
cout << sol.size() << "\n";
for (string tren : sol) cout << tren << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |