結果

問題 No.1964 sum = length
ユーザー myirumyiru
提出日時 2022-06-04 10:35:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 167,264 KB
実行使用メモリ 15,572 KB
最終ジャッジ日時 2023-10-21 02:36:23
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
15,572 KB
testcase_01 AC 13 ms
15,572 KB
testcase_02 WA -
testcase_03 AC 14 ms
15,572 KB
testcase_04 AC 13 ms
15,572 KB
testcase_05 AC 13 ms
15,572 KB
testcase_06 AC 14 ms
15,572 KB
testcase_07 AC 13 ms
15,572 KB
testcase_08 AC 13 ms
15,572 KB
testcase_09 AC 13 ms
15,572 KB
testcase_10 AC 13 ms
15,572 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MAX = 510000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n;cin>>n;
    COMinit();

    cout << COM(2*n-2, n-1) << endl;
}
0