結果

問題 No.2048 L(I+D)S
ユーザー RedstoneGamer22RedstoneGamer22
提出日時 2023-01-17 08:59:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 199,104 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 13:16:26
合計ジャッジ時間 3,957 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 20 ms
4,380 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 21 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int NMAX = 1e5 + 7;
const int mod = 998244353;
int fact[NMAX];

int lgpow(int b, int e) {
    int ret = 1;
    while(e) {
        if(e & 1) ret = (1LL * ret * b) % mod;
        b = (1LL * b * b) % mod;

        e /= 2;
    }
    return ret;
}

int main() {
    fact[0] = 1;
    for(int i = 1; i < NMAX; i++) fact[i] = (1LL * fact[i - 1] * i) % mod;

    int n; cin >> n;
    int ans = 0;
    for(int k = 2; k <= n - 2; k++) {
        int upper = fact[n];
        int lower = 1;
        lower = (1LL * lower * (n - 1)) % mod;
        lower = (1LL * lower * fact[k - 2]) % mod;
        lower = (1LL * lower * fact[n - k - 2]) % mod;
        lower = (1LL * lower * k) % mod;
        lower = (1LL * lower * (n - k)) % mod;

        int cnt = (1LL * upper * lgpow(lower, mod - 2)) % mod;
        ans = (1LL * ans + 1LL * cnt * cnt) % mod;
    }

    cout << ans << endl;
}
0