結果

問題 No.673 カブトムシ
ユーザー tonyu0
提出日時 2020-04-25 14:32:05
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 12,746 ms
コンパイル使用メモリ 390,772 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-07 01:41:32
合計ジャッジ時間 14,026 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
const MOD: u128 = 1_000_000_007;

fn mod_pow(mut x: u128, mut e: u128, m: u128) -> u128 {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % m;
        }
        x = x * x % m;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let b: u128 = itr.next().unwrap().parse::<u128>().unwrap();
    let c: u128 = itr.next().unwrap().parse::<u128>().unwrap();
    let d: u128 = itr.next().unwrap().parse::<u128>().unwrap();
    if c == 1 {
        println!("{}", b * d % MOD);
    } else {
        println!(
            "{}",
            b * c % MOD * (mod_pow(c, d, MOD) - 1) % MOD * mod_pow(c - 1, MOD - 2, MOD) % MOD
        );
    }
}
0