QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#459273 | #8834. Formal Fring | ucup-team1447# | WA | 0ms | 11488kb | C++14 | 2.1kb | 2024-06-30 00:20:11 | 2024-06-30 00:20:12 |
Judging History
answer
// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
const int MOD = 998244353;
struct mint
{
unsigned v;
mint(unsigned v_ = 0) : v(v_) {}
mint operator-() const { return v ? MOD - v : *this; }
mint &operator+=(const mint &X) { return (v += X.v) >= MOD ? v -= MOD : v, *this; }
mint &operator-=(const mint &X) { return (v += MOD - X.v) >= MOD ? v -= MOD : v, *this; }
mint &operator*=(const mint &X) { return v = 1llu * v * X.v % MOD, *this; }
mint &operator/=(const mint &X) { return *this *= X.inv(); }
mint pow(long long B) const
{
B %= MOD - 1;
if (B < 0)
B += MOD - 1;
mint res = 1, A = *this;
while (B)
{
if (B & 1)
res *= A;
B >>= 1;
A *= A;
}
return res;
}
mint inv() const { return pow(MOD - 2); }
friend mint operator+(const mint &A, const mint &B) { return mint(A) += B; }
friend mint operator-(const mint &A, const mint &B) { return mint(A) -= B; }
friend mint operator*(const mint &A, const mint &B) { return mint(A) *= B; }
friend mint operator/(const mint &A, const mint &B) { return mint(A) /= B; }
friend std::istream &operator>>(std::istream &A, mint &B) { return A >> B.v; }
friend std::ostream &operator<<(std::ostream &A, const mint &B) { return A << B.v; }
explicit operator bool() const { return v; }
} dp[1000005], h[1000005];
int n;
signed main()
{
std::ios::sync_with_stdio(false);
std::cin >> n;
dp[0] = 1;
for (int i = 0; i != 20; ++i)
for (int j = 1 << i; j <= n; ++j)
dp[j] += dp[j - (1 << i)];
for (int i = 1, k = 0; i <= n; ++i)
{
mint v = dp[i];
if (1 << k << 1 == i)
++k;
for (int j = 20; j--;)
if (1 << j < i && ~i >> j & 1)
{
v = (dp[i >> j >> 1] - dp[(i ^ 1 << k) >> j >> 1]) * dp[i & ((1 << j) - 1)] + dp[i ^ 1 << k];
break;
}
std::cout << v << " \n"[i == n];
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11428kb
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: 11488kb
input:
70
output:
1 1 2 1 1 3 6 1 1 2 2 5 5 10 26 1 1 2 2 4 4 6 6 11 11 16 16 24 24 46 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 98 98 122 122 160 160 306 1626 1 1 2 2 4 4 6
result:
wrong answer 14th numbers differ - expected: '11', found: '10'