結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー hebiyanhebiyan
提出日時 2017-05-23 14:54:50
言語 Rust
(1.72.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 7,964 ms
コンパイル使用メモリ 146,884 KB
実行使用メモリ 4,328 KB
最終ジャッジ日時 2023-10-19 15:32:07
合計ジャッジ時間 2,214 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,324 KB
testcase_01 AC 1 ms
4,328 KB
testcase_02 AC 1 ms
4,328 KB
testcase_03 AC 1 ms
4,328 KB
testcase_04 AC 1 ms
4,328 KB
testcase_05 AC 1 ms
4,328 KB
testcase_06 AC 1 ms
4,328 KB
testcase_07 AC 0 ms
4,328 KB
testcase_08 AC 1 ms
4,328 KB
testcase_09 AC 1 ms
4,328 KB
testcase_10 AC 1 ms
4,328 KB
testcase_11 AC 1 ms
4,328 KB
testcase_12 AC 1 ms
4,328 KB
testcase_13 AC 1 ms
4,328 KB
testcase_14 AC 0 ms
4,328 KB
testcase_15 AC 1 ms
4,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
    let mut s = String::new();

    std::io::stdin().read_line(&mut s).ok();

    s.trim().to_string()
}

fn powmod(b: u32, p: u32, m: u32) -> u32 {
    if b == 0 {
        0
    } else if p == 0 {
        1
    } else if p % 2 == 0 {
        let prev = powmod (b, p / 2, m);

        (prev * prev) % m
    } else {
        let prev = powmod (b, p - 1, m);

        (b * prev) % m
    }
}

fn answer(m: u32) -> u32 {
    (powmod(2017, 4034, m) + 2017) % m
}

fn main() {
    let s = getline();
    let m: u32 = s.parse().unwrap();

    println!("{}", answer(m));
}
0