# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
291670 | kingfran1907 | Popcount (COCI19_popcount) | C++14 | 1 ms | 384 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 = 2e5+10;
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< int > v;
void rek(int x) {
if (x == v.size() - 1) printf("(1<<%d)", v[x]);
else {
printf("((1<<%d)+", v[x]);
rek(x + 1);
printf(")");
}
}
int main() {
scanf("%d%d", &n, &k);
int log = 0;
int tren = 1;
while (tren < n) log++, tren *= 2;
printf("%d\n", log);
for (int i = 0; i < log; i++) {
int ac = (1 << i);
printf("A=(");
printf("(A&");
v.clear();
for (int j = 0; j < n; j += ac * 2) {
for (int l = 0; l < ac; l++) {
if (l + j >= n) break;
v.push_back(j + l);
}
}
rek(0);
printf(")+");
v.clear();
for (int j = ac; j < n; j += ac * 2) {
int l = min(n, j + ac);
if (l == n) {
printf("((A&");
for (int x = j; x < l; x++)
v.push_back(x);
rek(0);
printf(")>>%d)", ac);
} else printf("((A&((1<<%d)-(1<<%d)))>>%d)", l, j, ac);
if (j + ac * 2 < n) printf("+");
}
printf(")\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... |