QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#470262 | #8834. Formal Fring | NobodyThere | WA | 1ms | 7888kb | C++17 | 1.1kb | 2024-07-10 11:38:14 | 2024-07-10 11:38:14 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
constexpr int N = 1e6;
constexpr ll mod = 998244353;
int n;
ll f[N + 3], g[N + 3], sg[N + 3];
inline int lowbit(int x) {return x & -x;}
int main() {
scanf("%d", &n);
g[0] = sg[0] = 1;
for(int i = 1; i <= n; i++) {
g[i] = sg[i >> 1];
sg[i] = (sg[i - 1] + g[i]) % mod;
}
f[0] = f[1] = 1;
for(int x = 2, hb = 0; x <= n; x++) {
if(x + 1 == lowbit(x + 1)) {
f[x] = g[x]; continue;
}
if(x == lowbit(x)) ++hb;
int tmp = 0, y = x ^ (1 << hb);
f[x] = g[y];
for(int i = hb - 1; i >= 0; i--) {
if((x >> i & 1) == 0) break;
y ^= 1 << i;
++tmp;
ll dt = (g[(1 << (tmp + 1)) - 1] - g[(1 << tmp) - 1] * 2 + g[(1 << (tmp - 1)) - 1] + mod * 2) % mod;
f[x] = (f[x] + dt * g[y]) % mod;
}
}
for(int i = 1; i <= n; i++)
printf("%lld ", f[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7884kb
input:
10
output:
1 1 2 1 1 3 6 1 1 2
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7888kb
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 54 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 188 188 362 1626 1 1 2 2 4 4 6
result:
wrong answer 30th numbers differ - expected: '53', found: '54'