結果

問題 No.1681 +-*
ユーザー titiatitia
提出日時 2021-09-18 01:27:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 305 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 106,356 KB
最終ジャッジ日時 2023-09-12 11:46:07
合計ジャッジ時間 7,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,112 KB
testcase_01 AC 77 ms
71,416 KB
testcase_02 AC 80 ms
71,044 KB
testcase_03 AC 81 ms
71,160 KB
testcase_04 AC 80 ms
71,108 KB
testcase_05 AC 391 ms
106,336 KB
testcase_06 AC 389 ms
106,356 KB
testcase_07 AC 395 ms
106,244 KB
testcase_08 AC 427 ms
100,592 KB
testcase_09 AC 430 ms
100,288 KB
testcase_10 AC 429 ms
100,632 KB
testcase_11 AC 431 ms
100,312 KB
testcase_12 AC 432 ms
100,284 KB
testcase_13 AC 239 ms
91,552 KB
testcase_14 AC 406 ms
100,668 KB
testcase_15 AC 77 ms
71,156 KB
testcase_16 AC 76 ms
71,256 KB
testcase_17 AC 423 ms
100,576 KB
testcase_18 AC 420 ms
100,516 KB
testcase_19 AC 428 ms
100,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ANS=0
K=1

ALL=pow(3,N-1,mod)

for i in range(N):
    K=K*A[i]%mod

    if i!=N-1:
        ANS=ANS+K*ALL*2*pow(3,mod-2,mod)
    else:
        ANS=ANS+K*ALL
        
    ANS%=mod
    ALL=ALL*pow(3,mod-2,mod)%mod

    #print(ANS,ALL)

print(ANS)
0