結果

問題 No.1237 EXP Multiple!
ユーザー どららどらら
提出日時 2020-09-26 02:37:32
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 951 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 140,176 KB
実行使用メモリ 5,804 KB
最終ジャッジ日時 2023-09-10 20:01:25
合計ジャッジ時間 2,547 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 9 ms
4,512 KB
testcase_02 AC 11 ms
5,216 KB
testcase_03 AC 12 ms
5,308 KB
testcase_04 AC 13 ms
5,804 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 RE -
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;
use std::str::FromStr;

fn fact(x: i64) -> i64 {
    let mut ret = 1;
    for i in 1..=x {
        ret *= i;
    }
    ret
}

fn calc(n: i64, v: Vec<i64>) -> i64 {
    let mut ret = 1;
    for i in 0..n {
        let x = v[i as usize];
        if x == 0 {
            return -1;
        }
        if x >= 4 {
            return 1000_000_007_i64;
        }

        let mut p = 1;
        for _ in 0..fact(x) {
            p *= x;
        }
        ret *= p;
    }
    1000_000_007_i64 % ret
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|x| i64::from_str(x).unwrap());
    let n = itr.next().unwrap();

    s.clear();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|x| i64::from_str(x).unwrap());
    let mut v = Vec::new();
    for _i in 0..n {
        v.push(itr.next().unwrap());
    }

    println!("{}", calc(n, v));
}
0