QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767368#8834. Formal FringguosounAC ✓163ms10948kbC++17949b2024-11-20 20:43:372024-11-20 20:43:37

Judging History

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

  • [2024-11-20 20:43:37]
  • 评测
  • 测评结果:AC
  • 用时:163ms
  • 内存:10948kb
  • [2024-11-20 20:43:37]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC target "avx512dq"

using ll = long long;

const int mod = 998244353;

int main() {
  std::cin.tie(0)->sync_with_stdio(0);
  int n;
  std::cin >> n;
  std::vector<int> f(n + 1), g(n + 1);
  f[0] = 1;
  for (int i = 1; i <= n; i <<= 1) {
	  #pragma GCC unroll 99
    for (int j = i; j <= n; j++) 
      f[j] = (f[j] + f[j - i]) % mod;
  }
  g[0] = 1;
  for (int i = 1; i <= n; i++) {
	  #pragma GCC unroll 99
    for (int k = 1; k * 2 <= i; k <<= 1) {
      if ((i - k * 2) % k == 0) (g[i] += (ll)f[k] * g[(i - k * 2) / k] % mod) %= mod;
    } 
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int k = 1; k <= i; k <<= 1)
      if (i - k - i % k >= 0) {
        int x = k - i % k;
        if (std::__lg((i + x) / 2) == std::__lg((i - x) / 2)) continue;
        (ans += (ll)f[i % k] * g[(i - i % k - k) / k] % mod) %= mod;
      }
    std::cout << ans << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 163ms
memory: 10948kb

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