結果

問題 No.1681 +-*
ユーザー 👑 KazunKazun
提出日時 2021-09-17 22:23:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 108,564 KB
最終ジャッジ日時 2023-09-12 08:10:29
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,012 KB
testcase_01 AC 72 ms
71,156 KB
testcase_02 AC 75 ms
70,772 KB
testcase_03 AC 75 ms
70,780 KB
testcase_04 AC 74 ms
71,244 KB
testcase_05 AC 119 ms
108,488 KB
testcase_06 AC 116 ms
108,564 KB
testcase_07 AC 117 ms
108,488 KB
testcase_08 AC 135 ms
103,200 KB
testcase_09 AC 135 ms
103,020 KB
testcase_10 AC 136 ms
103,080 KB
testcase_11 AC 135 ms
103,056 KB
testcase_12 AC 134 ms
103,076 KB
testcase_13 AC 102 ms
92,720 KB
testcase_14 AC 134 ms
103,064 KB
testcase_15 AC 73 ms
70,840 KB
testcase_16 AC 74 ms
71,268 KB
testcase_17 AC 134 ms
103,032 KB
testcase_18 AC 133 ms
103,036 KB
testcase_19 AC 134 ms
103,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#==================================================
N=int(input())
A=[-1]+list(map(int,input().split()))

Mod=10**9+7
THREE=[1]*(N+1)
for i in range(1,N+1):
    THREE[i]=(3*THREE[i-1])%Mod

X=0
alpha=1
for i in range(1,N+1):
    alpha*=A[i]; alpha%=Mod

    if i==N:
        X+=alpha
    else:
        X+=alpha*THREE[N-1-i]*2
    X%=Mod

print(X)
0