QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#461690 | #8834. Formal Fring | ucup-team3678 | AC ✓ | 67ms | 12116kb | C++14 | 798b | 2024-07-02 22:46:06 | 2024-07-02 22:46:08 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, P = 998244353;
int f[N], g[N], h[N];
signed main() {
int n; scanf("%d", &n);
g[0] = 1;
for (int i = 1; i <= n; ++i) {
if (i & 1) g[i] = g[i - 1];
else ((g[i] = g[i - 1] + g[i >> 1]) >= P) && (g[i] -= P);
}
for (int i = 1; i <= 19; ++i) {
h[i] = g[(1 << i) - 1];
for (int j = 1; j < i; ++j) h[i] = (h[i] + 1ll * (P - h[j]) * g[(1 << (i - j)) - 1]) % P;
}
for (int i = 1, k = 0; i <= n; ++i) {
while ((1 << (k + 1)) <= i) ++k;
for (int j = k; ~j && ((i >> j) & 1); --j) {
f[i] = (f[i] + 1ll * g[i & ((1 << j) - 1)] * h[k - j + 1]) % P;
}
printf("%d%c", f[i], " \n"[i == n]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6028kb
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: 5980kb
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: 67ms
memory: 12116kb
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