結果

問題 No.1084 積の積
ユーザー nehan_der_thal
提出日時 2020-06-19 22:53:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 81,980 KB
実行使用メモリ 109,180 KB
最終ジャッジ日時 2024-07-03 15:22:10
合計ジャッジ時間 5,744 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 RE * 1
other AC * 23 WA * 1 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

N, = map(int, input().split())
mod = 10**9+7
X = list(map(int, input().split()))
X.append(10**9+7)
j = 0
sm = 1
Cs = [0]*N
for i in range(N):
    while sm*X[j]<=10**9:
        sm *= X[j]
#        print(j, X[j], sm, j-i)
#        Cs[j] += j-i
        j += 1
    Cs[i] += j-i
    sm//=X[i]
#print(Cs)
D = []
for i in range(N):
    D.append((i*2, Cs[i]))
    D.append(((i+Cs[i])*2+1, Cs[i]))
#print(sorted(D))

D = sorted(D)
R = 1
cnt = 0
xm = 0
for idx, c in D:
    if idx%2:
        cnt -= 1
    else:
        idx //= 2
        xm -= cnt
#        print(xm, cnt, c+xm)
        R = R * pow(X[idx], c+xm, mod) % mod
        cnt += 1
        xm += c
print(R)

0