QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#711804#8834. Formal FringIllusionaryWhiteTravelerWA 0ms30224kbC++201.4kb2024-11-05 13:33:282024-11-05 13:33:29

Judging History

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

  • [2024-11-05 13:33:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:30224kb
  • [2024-11-05 13:33:28]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000000 + 5;
const int P = 998244353;

int N, M, f[20][MAX_N], g[20][MAX_N];

inline int add(int a, int b) {return a + b < P ? a + b : a + b - P;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin >> N;
    for (M = 0; (1 << M + 1) <= N; M ++);
    f[0][0] = 1; g[M][0] = 1;
    for (int i = 0; i <= M; i ++) {
        if (i > 0) {
            memcpy(f[i], f[i - 1], sizeof(int) * (N + 1));
        }
        int k = 1 << i;
        for (int j = 0; j + k <= N; j ++) {
            f[i][j + k] = add(f[i][j + k], f[i][j]);
        }
    }
    for (int i = M; i >= 0; i --) {
        if (i < M) {
            memcpy(g[i], g[i + 1], sizeof(int) * (N + 1));
        }
        int k = 1 << i;
        for (int j = 0; j + k <= N; j ++) {
            g[i][j + k] = add(g[i][j + k], g[i][j]);
        }
    }
    for (int i = 1, j, k; i <= N; i ++) {
        int ans = 0;
        for (j = M; ~ i >> j & 1; j --);
        for (k = j; k >= 0 && i >> k & 1; k --);
        if (k < 0) {
            k ++;
            ans = g[0][i];
        }else {
            for ( ; k < j; j --) {
                ans = (ans + 1ll * f[k][i & (1 << j) - 1] * g[j][i >> j << j]) % P;
            }
        }
        cout << ans << "\n "[i < N];
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 18004kb

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: 30224kb

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 9 26 1 1 2 2 4 4 6 6 11 11 16 16 19 19 35 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 73 73 92 92 73 73 201 1626 1 1 2 2 4 4 6

result:

wrong answer 14th numbers differ - expected: '11', found: '9'