結果

問題 No.1681 +-*
ユーザー brthyyjpbrthyyjp
提出日時 2021-09-17 22:02:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,636 KB
実行使用メモリ 115,068 KB
最終ジャッジ日時 2023-09-12 07:35:41
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
83,504 KB
testcase_01 AC 86 ms
83,360 KB
testcase_02 AC 89 ms
83,596 KB
testcase_03 AC 89 ms
83,448 KB
testcase_04 AC 87 ms
83,516 KB
testcase_05 AC 129 ms
115,068 KB
testcase_06 AC 129 ms
114,772 KB
testcase_07 AC 127 ms
114,812 KB
testcase_08 AC 145 ms
109,392 KB
testcase_09 AC 145 ms
109,168 KB
testcase_10 AC 145 ms
109,552 KB
testcase_11 AC 145 ms
109,152 KB
testcase_12 AC 143 ms
109,248 KB
testcase_13 AC 111 ms
99,860 KB
testcase_14 AC 140 ms
109,160 KB
testcase_15 AC 86 ms
83,360 KB
testcase_16 AC 86 ms
83,424 KB
testcase_17 AC 143 ms
109,244 KB
testcase_18 AC 144 ms
109,420 KB
testcase_19 AC 143 ms
109,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

C = [0]*n
C[0] = A[0]
for i in range(1, n):
    C[i] = C[i-1]*A[i]
    C[i] %= mod

N = 10**6
P = [0]*N
P[0] = 1
for i in range(1, N):
    P[i] = P[i-1]*3
    P[i] %= mod
ans = 0
for i in range(n-1):
    ans += C[i]*2*P[n-2-i]
    ans %= mod
ans += C[-1]
ans %= mod
print(ans)
0