結果

問題 No.2023 Tiling is Fun
ユーザー phsplsphspls
提出日時 2022-09-04 00:12:25
言語 Rust
(1.77.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 13,276 ms
コンパイル使用メモリ 379,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 20:26:02
合計ジャッジ時間 14,802 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 13 ms
5,248 KB
testcase_02 AC 11 ms
5,376 KB
testcase_03 AC 20 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 AC 23 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 AC 25 ms
5,376 KB
testcase_09 AC 35 ms
5,376 KB
testcase_10 AC 13 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 37 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 37 ms
5,376 KB
testcase_18 AC 37 ms
5,376 KB
testcase_19 AC 37 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 998244353;

fn power(base: usize, times: usize) -> usize {
    if times == 0 { return 1usize; }
    if times == 1 { return base; }
    let temp = power(base, times/2);
    temp * temp % MOD * power(base, times%2) % MOD
}

fn comb(n: usize, r: usize) -> usize {
    let mut ret = 1usize;
    for i in 1..=r {
        ret *= n+1-i;
        ret %= MOD;
        ret *= power(i, MOD-2);
        ret %= MOD;
    }
    ret
}

fn main() {
    let mut ab = String::new();
    std::io::stdin().read_line(&mut ab).ok();
    let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = ab[0];
    let b = ab[1];

    println!("{}", comb(a+b-2, a-1));
}
0