結果

問題 No.403 2^2^2
ユーザー koba-e964koba-e964
提出日時 2016-08-04 00:29:35
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,556 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 157,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:16:07
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 0 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 0 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 WA -
testcase_29 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }


const MOD: i64 = 1_000_000_007;

fn powmod(a: i64, b: i64, m: i64) -> i64 {
    let mut sum: i64 = 1;
    let mut cur: i64 = a;
    let mut e = b;
    while e > 0 {
        if e % 2 == 1 {
            sum = sum * cur % m;
        }
        cur = cur * cur % m;
        e /= 2;
    }
    sum
}
fn main() {
    let v: Vec<i64> = get_word().split("^").map(|v| parse::<i64>(v)).collect::<Vec<i64>>();
    print!("{} ", powmod(powmod(v[0], v[1], MOD), v[2], MOD));
    let mut e = powmod(v[1], v[2], MOD - 1);
    if v[1] >= 1 && e == 0 {
        e = MOD - 1;
    }
    println!("{}", powmod(v[0], e, MOD));
}
0