結果

問題 No.1681 +-*
ユーザー mymelochanmymelochan
提出日時 2021-09-17 22:05:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 86,632 KB
実行使用メモリ 133,392 KB
最終ジャッジ日時 2023-09-12 07:44:06
合計ジャッジ時間 4,444 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,184 KB
testcase_01 AC 71 ms
71,276 KB
testcase_02 AC 75 ms
71,272 KB
testcase_03 AC 73 ms
70,896 KB
testcase_04 AC 74 ms
71,340 KB
testcase_05 AC 142 ms
133,392 KB
testcase_06 AC 135 ms
133,352 KB
testcase_07 AC 136 ms
133,220 KB
testcase_08 AC 150 ms
127,528 KB
testcase_09 AC 151 ms
127,452 KB
testcase_10 AC 151 ms
127,492 KB
testcase_11 AC 150 ms
127,440 KB
testcase_12 AC 151 ms
127,360 KB
testcase_13 AC 109 ms
103,820 KB
testcase_14 AC 149 ms
127,356 KB
testcase_15 AC 71 ms
71,192 KB
testcase_16 AC 71 ms
71,152 KB
testcase_17 AC 149 ms
127,452 KB
testcase_18 AC 150 ms
127,480 KB
testcase_19 AC 149 ms
127,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

p2 = [1]
p3 = [1]
for _ in range(N+10):
    p2.append(p2[-1]*2%MOD)
    p3.append(p3[-1]*3%MOD)
for _ in range(10):
    p3.append(1)

ans = 0
t = 1
for i in range(N):
    t *= A[i]
    t %= MOD
    tmp = t*p3[N-i-2]%MOD
    if i != N-1:
        tmp*=2
    ans += tmp
    ans %= MOD
print(ans)
0