QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767306 | #8834. Formal Fring | forgotmyhandle | RE | 0ms | 0kb | C++14 | 879b | 2024-11-20 20:28:55 | 2024-11-20 20:29:01 |
answer
#include <iostream>
#define int long long
using namespace std;
const int P = 998244353;
int n;
int dp[1000005], g[1000005], h[1000005];
signed main() {
ios::sync_with_stdio(false); cout.tie(0);
cin >> n;
dp[0] = 1;
for (int i = 1; i <= n; i++) {
dp[i] = (dp[i - 1] + ((i & 1) ? 0 : dp[i >> 1])) % P;
h[i] = (((i & (i + 1)) == 0) ? __builtin_popcountll(i) : h[i >> 1]);
}
for (int i = 1; i <= 20; i++) {
g[i] = dp[(1 << i) - 1];
for (int j = 1; j < i; j++)
g[i] = (g[i] + (P - g[j]) * dp[(1 << (i - j)) - 1]) % P;
}
for (int i = 1, x = -1; i <= n; i++) {
int tmp = 0;
x += ((i & (i - 1)) == 0);
for (int j = 1; j <= h[i]; j++)
tmp += g[j] * dp[i ^ (((1 << j) - 1) << (x - j + 1))] % P;
cout << tmp % P << " ";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
10