結果

問題 No.1681 +-*
ユーザー ああいい
提出日時 2021-12-03 22:34:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 32,656 KB
最終ジャッジ日時 2024-07-06 06:05:55
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
P = 10 ** 9 + 7

inv = [0] * 4
inv[1] = 1
inv[2] = P - P // 2
inv[3] = P - P // 3 * inv[P % 3] % P
c = 1
for _ in range(N-2):
    c *= 3
    c %= P

now = A[0] * 2 * c % P
s = now
for i in range(2,N):
    now = now * inv[3] * A[i-1] % P
    s += now
    s %= P
now = now * inv[2] * A[N-1] % P
s += now
s %= P
print(s)
0