QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#460064#8834. Formal Fringucup-team3215AC ✓18ms5604kbC++20810b2024-06-30 20:49:362024-06-30 20:49:42

Judging History

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

  • [2024-06-30 20:49:42]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:5604kb
  • [2024-06-30 20:49:36]
  • 提交

answer

#include <cstdint>
#include <iostream>

using namespace std;

constexpr int N = 1e6 + 2, L = 20, mod = 998244353;

int part[N / 2], trap[L];

int main() {
  int n; cin >> n;
  for (int i = 1, s = part[0] = 1; i * 2 <= n; ++i) part[i] = s = (s + part[i / 2]) % mod;
  for (int i = 0; i < L; ++i) {
    trap[i] = part[(1 << i) - 1 >> 1];
    for (int j = 1; j < i; ++j) trap[i] = (trap[i] + mod * (uint64_t)mod - trap[j] * (uint64_t)part[(1 << i - j) - 1 >> 1]) % mod;
  }
  int j = 0;
  string s;
  for (int i = 1; i <= n; ++i) {
    j += 1 << j <= i;
    uint64_t ans{};
    for (int l = j; l-- && (i >> l & 1); ) ans += trap[j - l] * (uint64_t)part[(i & (1 << l) - 1) >> 1];
    s += to_string(ans % mod) + ' ';
    if (s.size() >= 1 << 14) cout << s, s.clear();
  }
  cout << s;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 18ms
memory: 5604kb

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