結果
問題 | No.1237 EXP Multiple! |
ユーザー | どらら |
提出日時 | 2020-09-26 02:38:29 |
言語 | Rust (1.77.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,035 bytes |
コンパイル時間 | 3,965 ms |
コンパイル使用メモリ | 136,348 KB |
実行使用メモリ | 5,804 KB |
最終ジャッジ日時 | 2023-09-10 20:04:04 |
合計ジャッジ時間 | 3,262 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 9 ms
4,504 KB |
testcase_02 | AC | 12 ms
5,256 KB |
testcase_03 | AC | 12 ms
5,292 KB |
testcase_04 | AC | 13 ms
5,804 KB |
testcase_05 | AC | 6 ms
4,380 KB |
testcase_06 | AC | 6 ms
4,380 KB |
testcase_07 | AC | 6 ms
4,380 KB |
testcase_08 | AC | 7 ms
4,380 KB |
testcase_09 | AC | 6 ms
4,376 KB |
testcase_10 | AC | 6 ms
4,376 KB |
testcase_11 | AC | 5 ms
4,376 KB |
testcase_12 | AC | 6 ms
4,380 KB |
testcase_13 | AC | 7 ms
4,380 KB |
testcase_14 | AC | 7 ms
4,380 KB |
testcase_15 | AC | 7 ms
4,376 KB |
testcase_16 | AC | 7 ms
4,376 KB |
testcase_17 | AC | 7 ms
4,380 KB |
testcase_18 | AC | 7 ms
4,380 KB |
testcase_19 | WA | - |
ソースコード
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; if ret >= 1000_000_007_i64 { return 1000_000_007_i64; } } 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)); }