結果

問題 No.1206 OR, OR, OR......
ユーザー phsplsphspls
提出日時 2020-10-01 11:09:56
言語 Rust
(1.72.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 146,100 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 06:47:46
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let t: u8 = t.trim().parse().unwrap();
    for _ in 0..t {
        let mut nk = String::new();
        std::io::stdin().read_line(&mut nk).ok();
        let nk: Vec<u64> = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let n = nk[0];
        let k = nk[1];
        println!("{}", n * (power(2, k) - 1) % DIVISOR * power(2, (n - 1) * k) % DIVISOR);
    }
}
0