結果

問題 No.2023 Tiling is Fun
ユーザー phspls
提出日時 2022-09-04 00:12:25
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 19,854 ms
コンパイル使用メモリ 378,324 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 15:49:15
合計ジャッジ時間 14,761 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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