QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#471872 | #8834. Formal Fring | SunsetGlow95 | AC ✓ | 213ms | 11488kb | C++20 | 1000b | 2024-07-11 10:39:56 | 2024-07-11 10:39:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1000005;
const int DVS = 998244353;
int N, cnt[MXN], bcnt[MXN];
int main() {
cin >> N;
cnt[0] = bcnt[0] = 1;
for (int i(1); i <= N; i <<= 1) {
for (int j(i); j <= N; ++j) cnt[j] = (cnt[j] + cnt[j - i]) % DVS;
}
for (int i(1); i <= N; ++i) {
bcnt[i] = cnt[i];
for (int j(1); j <= i; j <<= 1)
if (i & j)
bcnt[i] = (bcnt[i] - bcnt[i / j - 1] * 1LL * cnt[i % j] % DVS + DVS) % DVS;
}
// for (int i(1); i <= N; ++i) cout << cnt[i] << ' ';
// cout << endl;
// for (int i(1); i <= N; ++i) cout << bcnt[i] << ' ';
// cout << endl;
for (int i(1); i <= N; ++i) {
int hb(1);
while (hb <= i) hb <<= 1;
hb >>= 1;
int d(min(i - hb, 2 * hb - 2 - i));
int o(0);
for (int j(1); j <= i; j <<= 1)
if (i & j && j - (i % j) > d)// cout << i << ':' << j << endl,
o = (o + bcnt[i / j - 1] * 1LL * cnt[i % j] % DVS) % DVS;
cout << o << ' ';
}
cout << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5588kb
input:
10
output:
1 1 2 1 1 3 6 1 1 2
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 5604kb
input:
70
output:
1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6
result:
ok 70 numbers
Test #3:
score: 0
Accepted
time: 213ms
memory: 11488kb
input:
1000000
output:
1 1 2 1 1 3 6 1 1 2 2 5 5 11 26 1 1 2 2 4 4 6 6 11 11 16 16 27 27 53 166 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 37 37 48 48 64 64 80 80 107 107 134 134 187 187 353 1626 1 1 2 2 4 4 6 6 10 10 14 14 20 20 26 26 36 36 46 46 60 60 74 74 94 94 114 114 140 140 166 166 203 203 240 240 288 288 336 336 400 ...
result:
ok 1000000 numbers
Extra Test:
score: 0
Extra Test Passed