QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#459294#8834. Formal Fringucup-team1447#AC ✓46ms11552kbC++142.2kb2024-06-30 01:00:352024-06-30 01:00:36

Judging History

你现在查看的是最新测评结果

  • [2024-06-30 01:00:36]
  • 评测
  • 测评结果:AC
  • 用时:46ms
  • 内存:11552kb
  • [2024-06-30 01:00:35]
  • 提交

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)];
    h[0] = 1;
    for (int i = 1; i != 20; ++i)
    {
        h[i] = dp[(1 << i) - 1];
        for (int j = 1; j != i; ++j)
            h[i] -= h[i - j] * dp[(1 << j) - 1];
    }
    for (int i = 1, k = 0; i <= n; ++i)
    {
        mint v = 0;
        if (1 << k << 1 == i)
            ++k;
        for (int j = k; ~j; --j)
            if (i >> j & 1)
                v += h[k - j + 1] * dp[i & ((1 << j) - 1)];
            else
                break;
        std::cout << v << " \n"[i == n];
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 11544kb

input:

10

output:

1 1 2 1 1 3 6 1 1 2

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 11444kb

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: 46ms
memory: 11552kb

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