QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767306#8834. Formal FringforgotmyhandleRE 0ms0kbC++14879b2024-11-20 20:28:552024-11-20 20:29:01

Judging History

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

  • [2024-11-20 20:29:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-20 20:28:55]
  • 提交

answer

#include <iostream>
#define int long long
using namespace std;
const int P = 998244353;
int n;
int dp[1000005], g[1000005], h[1000005];
signed main() {
    ios::sync_with_stdio(false); cout.tie(0);
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i] = (dp[i - 1] + ((i & 1) ? 0 : dp[i >> 1])) % P;
        h[i] = (((i & (i + 1)) == 0) ? __builtin_popcountll(i) : h[i >> 1]);
    }
    for (int i = 1; i <= 20; i++) {
        g[i] = dp[(1 << i) - 1];
        for (int j = 1; j < i; j++) 
            g[i] = (g[i] + (P - g[j]) * dp[(1 << (i - j)) - 1]) % P;
    }
    for (int i = 1, x = -1; i <= n; i++) {
        int tmp = 0;
        x += ((i & (i - 1)) == 0);
        for (int j = 1; j <= h[i]; j++) 
            tmp += g[j] * dp[i ^ (((1 << j) - 1) << (x - j + 1))] % P;
        cout << tmp % P << " ";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

10

output:


result: