結果

問題 No.1681 +-*
ユーザー hogehogehogehoge
提出日時 2021-09-17 22:25:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 30,032 KB
最終ジャッジ日時 2023-09-12 08:15:39
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 16 ms
7,968 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 16 ms
7,864 KB
testcase_04 AC 16 ms
7,792 KB
testcase_05 AC 221 ms
29,852 KB
testcase_06 AC 219 ms
29,860 KB
testcase_07 AC 217 ms
29,820 KB
testcase_08 AC 246 ms
30,024 KB
testcase_09 AC 250 ms
30,032 KB
testcase_10 AC 251 ms
29,860 KB
testcase_11 AC 248 ms
29,980 KB
testcase_12 AC 249 ms
30,032 KB
testcase_13 AC 114 ms
19,092 KB
testcase_14 AC 214 ms
29,896 KB
testcase_15 AC 15 ms
7,880 KB
testcase_16 AC 15 ms
7,840 KB
testcase_17 AC 233 ms
29,900 KB
testcase_18 AC 233 ms
29,936 KB
testcase_19 AC 247 ms
29,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
e = 1000000007
alist = []
three = []
temp = 1
th = 1
for i in range(n):
    #temp = temp*a[i]
    #alist.append(temp)
    three.append(th)
    th = th*3%e

#print(three)

ans = 0
for j in range(n-1):
    temp = temp*a[j]%e
    ans += (temp*2*three[n-2-j])%e 
temp = temp*(a[n-1]%e)%e
ans = (ans+temp)%e

print(ans)
0