結果

問題 No.1184 Hà Nội
コンテスト
ユーザー phspls
提出日時 2020-09-05 17:19:23
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 543 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,663 ms
コンパイル使用メモリ 185,568 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-22 23:23:52
合計ジャッジ時間 5,415 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

const DIVISOR: u64 = 998244353;

fn power(base: u64, p: u64) -> u64 {
    if p == 0 { return 1; }
    if p == 1 { return base; }
    let temp = power(base, p / 2);
    temp % DIVISOR * temp % DIVISOR * power(base, p % 2) % DIVISOR
}

fn main() {
    let mut nl = String::new();
    std::io::stdin().read_line(&mut nl).ok();
    let nl: Vec<u64> = nl.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nl[0] / nl[1] + if nl[0] % nl[1] > 0 { 1 } else { 0 };

    println!("{}", (power(2, n) + DIVISOR - 1) % DIVISOR);
}
0