CE:Nothing is compiled: OUTPUT exceeds.
查看原帖
CE:Nothing is compiled: OUTPUT exceeds.
1309434
t7424fd楼主2025/2/5 17:16

rt.

Submission: 201434134

Code:

#include <bits/stdc++.h>

using namespace std;

const int N = 2e6 + 5, P = 998244353;

int n, m, ans, fact[N] = {1}, inv[N] = {0, 1}, invf[N] = {1};

int main()
{
    cin.tie(nullptr)->sync_with_stdio(false), cin >> n, m = ++n << 1;
    for (int i = 1; i <= m; i++) fact[i] = 1ll * fact[i - 1] * i % P;
    for (int i = 2; i <= m; i++) inv[i] = 1ll * inv[P % i] * (P - P / i) % P;
    for (int i = 1; i <= m; i++) invf[i] = 1ll * invf[i - 1] * inv[i] % P;
    for (int i = 0, t; i <= n; i += 3) t = (i + 1ll) * fact[m - i] % P * invf[m - i - n] % P, i & 1 ? (ans += P - t) %= P : (ans += t) %= P;
    cout << (1ll * ans * invf[n] % P * inv[n + 1] % P + P - 1) % P << '\n';
    return 0;
}
2025/2/5 17:16
加载中...