結果

問題 No.557 点対称
ユーザー tonyu0
提出日時 2020-03-28 11:40:17
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 13,575 ms
コンパイル使用メモリ 404,476 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 10:59:31
合計ジャッジ時間 15,118 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fn pow(mut x: u64, mut e: u64) -> u64 {
    let mut res = 1u64;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        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 n: u64 = itr.next().unwrap().parse().unwrap();
    if n == 1 {
        println!("2");
        return;
    }

    let mut ans = 4u64 * pow(5, n / 2 - 1) % MOD;

    if n & 1 == 1 {
        ans = (ans * 3) % MOD;
    }

    println!("{}", ans);
}
0