結果

問題 No.1084 積の積
ユーザー tyawanmusityawanmusi
提出日時 2020-06-13 16:43:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 18,952 KB
最終ジャッジ日時 2023-09-16 10:07:29
合計ジャッジ時間 6,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,820 KB
testcase_01 AC 14 ms
7,736 KB
testcase_02 AC 14 ms
7,780 KB
testcase_03 AC 15 ms
7,780 KB
testcase_04 AC 374 ms
17,292 KB
testcase_05 AC 31 ms
10,124 KB
testcase_06 AC 365 ms
17,132 KB
testcase_07 AC 15 ms
8,300 KB
testcase_08 AC 15 ms
7,888 KB
testcase_09 AC 43 ms
18,208 KB
testcase_10 AC 15 ms
8,100 KB
testcase_11 AC 23 ms
8,492 KB
testcase_12 AC 110 ms
12,636 KB
testcase_13 AC 222 ms
17,392 KB
testcase_14 AC 88 ms
11,768 KB
testcase_15 AC 79 ms
11,520 KB
testcase_16 AC 246 ms
18,952 KB
testcase_17 AC 103 ms
12,392 KB
testcase_18 AC 169 ms
15,224 KB
testcase_19 AC 214 ms
17,788 KB
testcase_20 AC 62 ms
10,284 KB
testcase_21 AC 88 ms
11,796 KB
testcase_22 AC 70 ms
10,980 KB
testcase_23 AC 138 ms
13,668 KB
testcase_24 AC 127 ms
13,168 KB
testcase_25 AC 220 ms
17,568 KB
testcase_26 AC 266 ms
18,684 KB
testcase_27 AC 273 ms
18,612 KB
testcase_28 AC 263 ms
18,512 KB
testcase_29 AC 259 ms
18,484 KB
testcase_30 AC 264 ms
18,488 KB
testcase_31 AC 271 ms
18,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Writer解
n = int(input())
a = list(map(int, input().split()))
a.append(10**9)
mod = 10**9+7

if 0 in a:
  	print(0)
  	exit()

p = [0]*n
s = 1
j = 0
for i in range(n):
	while s*a[j] < 10**9:
		s *= a[j]
		j += 1
	p[i] = j-i
	s //= a[i]

imos = [0]*(n+1)
for i in range(n):
  	imos[i] += 1
  	imos[i+p[i]] -= 1
for i in range(n):
  	imos[i+1] += imos[i]
for i in range(n):
	if i!=0:
		imos[i-1] -= p[i]
for i in range(n, 0, -1):
  	imos[i-1] += imos[i]
ans=1
for i in range(n):
  	ans *= pow(a[i], imos[i], mod)
  	ans %= mod
print(ans)
0