結果

問題 No.1084 積の積
ユーザー simansiman
提出日時 2022-11-29 01:39:47
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 664 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2024-04-15 22:43:37
合計ジャッジ時間 5,722 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,288 KB
testcase_01 AC 89 ms
12,160 KB
testcase_02 AC 88 ms
12,160 KB
testcase_03 AC 90 ms
12,416 KB
testcase_04 AC 237 ms
20,864 KB
testcase_05 RE -
testcase_06 AC 240 ms
20,992 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 96 ms
12,160 KB
testcase_12 AC 127 ms
16,128 KB
testcase_13 AC 166 ms
19,968 KB
testcase_14 AC 118 ms
14,720 KB
testcase_15 AC 117 ms
14,464 KB
testcase_16 AC 181 ms
21,760 KB
testcase_17 AC 122 ms
15,232 KB
testcase_18 AC 150 ms
18,048 KB
testcase_19 AC 170 ms
19,968 KB
testcase_20 AC 107 ms
13,696 KB
testcase_21 AC 118 ms
14,848 KB
testcase_22 AC 109 ms
14,080 KB
testcase_23 AC 133 ms
17,024 KB
testcase_24 AC 130 ms
16,640 KB
testcase_25 AC 165 ms
20,096 KB
testcase_26 AC 179 ms
20,864 KB
testcase_27 AC 181 ms
20,864 KB
testcase_28 AC 179 ms
20,992 KB
testcase_29 AC 181 ms
20,864 KB
testcase_30 AC 180 ms
21,120 KB
testcase_31 AC 180 ms
20,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
L = 10 ** 9
MOD = 10 ** 9 + 7

rui = Array.new(2 * N, 0)
counter = Array.new(N, 0)
l = 0
r = 0
val = A[0]

while l <= r
  # pp [:l, l, :r, r]

  if val >= L
    len = r - l
    counter[l] = len
    rui[l + 1] -= 1
    rui[l + len + 1] += 1

    val /= A[l]
    l += 1
  elsif r == N - 1
    len = r - l + 1
    counter[l] = len
    rui[l + 1] -= 1
    rui[l + len + 1] += 1

    val /= A[l]
    l += 1
  else
    r += 1
    val *= A[r]
  end
end

# pp rui
# pp counter
ans = 1
cnt = 0
sub = 0

N.times do |i|
  a = A[i]

  cnt += counter[i]
  sub += rui[i]
  cnt += sub

  ans *= a.pow(cnt, MOD)
  ans %= MOD
end

puts ans
0