結果

問題 No.1237 EXP Multiple!
ユーザー simansiman
提出日時 2020-09-26 07:34:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,284 KB
実行使用メモリ 29,972 KB
最終ジャッジ日時 2023-09-11 02:19:22
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
14,992 KB
testcase_01 AC 135 ms
24,680 KB
testcase_02 AC 156 ms
27,968 KB
testcase_03 AC 157 ms
28,488 KB
testcase_04 AC 158 ms
28,668 KB
testcase_05 AC 145 ms
26,928 KB
testcase_06 AC 147 ms
27,016 KB
testcase_07 AC 145 ms
26,788 KB
testcase_08 AC 240 ms
29,816 KB
testcase_09 AC 145 ms
26,968 KB
testcase_10 AC 144 ms
26,872 KB
testcase_11 AC 148 ms
26,856 KB
testcase_12 AC 149 ms
26,972 KB
testcase_13 AC 243 ms
29,880 KB
testcase_14 AC 243 ms
29,820 KB
testcase_15 AC 249 ms
29,772 KB
testcase_16 AC 247 ms
29,812 KB
testcase_17 AC 242 ms
29,812 KB
testcase_18 AC 245 ms
29,972 KB
testcase_19 AC 148 ms
27,016 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7
min_a, max_a = A.minmax

if min_a == 0
  puts -1
  exit
end

if max_a >= 4
  puts MOD
  exit
end

res = 1

A.each do |a|
  res *= a.pow((1..a).inject(:*))

  if res > MOD
    puts MOD
    exit
  end
end

puts MOD % res
0