QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543594#8834. Formal Fringucup-team1069#WA 0ms3784kbC++201.4kb2024-09-01 17:23:162024-09-01 17:23:21

Judging History

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

  • [2024-09-01 17:23:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-09-01 17:23:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define sz(x) (int)x.size();
#define all(x) x.begin(), x.end();

const int N = 1e6 + 200;
const int mod = 998244353;

int n, f[N];

void solve() {
    cin >> n;
    f[0] = 1;
    f[1] = 1;
    for (int i = 2; i <= n; ++i) {
        f[i] = f[i - 1];
        if (i % 2 == 0) {
            f[i] += f[i / 2];
            f[i] %= mod;
        }
    }
    for (int i = 1; i <= n; ++i) {
        /* if (i != 2) continue; */
        int l = 0;
        int j = i, p = 1;
        while (true) {
            if (__builtin_popcount(j + 1) == 1) {
                break;
            }
            if (j & 1) {
                l += p;
            }
            j /= 2;
            p *= 2;
        }
        int r = i - l;
        while (r % 2 == 0) r /= 2;
        if (r == i) {
            cout << f[r] << " ";
            continue;
        }
        int cnt = 0;
        int pw = -1;
        while (r >= 1) {
            int L = f[l];
            if (pw != -1) L = (L - f[l - pw] + mod) % mod;
            cnt += f[r] * 1ll * L % mod;
            cnt %= mod;
            /* cout << l << " " << r << '\n'; */
            r /= 2;
            l += p;
            pw = p;
            p *= 2;
        }
        cout << cnt << " ";
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    /* cin >> T; */
    while (T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

70

output:

1 1 2 1 1 3 6 1 1 2 2 5 5 12 26 1 1 2 2 4 4 6 6 11 11 16 16 28 28 60 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 108 108 136 136 196 196 396 1626 1 1 2 2 4 4 6 

result:

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