結果

問題 No.673 カブトムシ
ユーザー lzy9lzy9
提出日時 2018-04-14 20:47:42
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 1,379 ms
コンパイル使用メモリ 148,272 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 05:28:00
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused imports: `max`, `min`
 --> Main.rs:3:16
  |
3 | use std::cmp::{min, max};
  |                ^^^  ^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `std::mem::swap`
 --> Main.rs:4:5
  |
4 | use std::mem::swap;
  |     ^^^^^^^^^^^^^^

warning: unused import: `std::collections::HashMap`
 --> Main.rs:5:5
  |
5 | use std::collections::HashMap;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^

warning: static `DX` is never used
  --> Main.rs:19:8
   |
19 | static DX: &'static [i32] = &[0, 0, 1, -1];
   |        ^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: static `DY` is never used
  --> Main.rs:20:8
   |
20 | static DY: &'static [i32] = &[1, -1, 0, 0];
   |        ^^

warning: 5 warnings emitted

ソースコード

diff #

use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};
use std::mem::swap;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

static DX: &'static [i32] = &[0, 0, 1, -1];
static DY: &'static [i32] = &[1, -1, 0, 0];

fn main() {
    let b: u64 = read();
    let c: u64 = read();
    let d: u64 = read();

    let m = 1000000007u64;

    let mut p = pow_mod(c, d + 1, m);

    p = ((p + m - (c % m)) * (b % m)) % m;

    p = p * pow_mod(c - 1, m - 2, m) % m;

    println!("{}", p);
}

fn pow_mod(mut n: u64, mut exp: u64, m: u64) -> u64 {
    let mut t = 1;

    n %= m;

    while exp > 1 {
        if exp & 1 == 1 {
            t *= n;
            t %= m;
        }

        n *= n;
        n %= m;
        exp >>= 1;
    }

    (n * t) % m
}
0