結果

問題 No.2007 Arbitrary Mod (Easy)
ユーザー phspls
提出日時 2022-09-06 11:54:41
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 16,998 ms
コンパイル使用メモリ 390,244 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 13:22:15
合計ジャッジ時間 18,491 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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 main() {
    let mut an = String::new();
    std::io::stdin().read_line(&mut an).ok();
    let an: Vec<usize> = an.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = an[0];
    let n = an[1];

    println!("{}", MOD);
    println!("{}", power(a, n));
}
0