結果

問題 No.1681 +-*
ユーザー tassei903tassei903
提出日時 2021-09-17 22:02:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 917 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 105,812 KB
最終ジャッジ日時 2023-09-12 07:37:44
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,148 KB
testcase_01 AC 72 ms
71,492 KB
testcase_02 AC 73 ms
71,476 KB
testcase_03 AC 74 ms
71,144 KB
testcase_04 AC 75 ms
71,412 KB
testcase_05 AC 195 ms
105,796 KB
testcase_06 AC 194 ms
105,812 KB
testcase_07 AC 195 ms
105,660 KB
testcase_08 AC 205 ms
100,476 KB
testcase_09 AC 206 ms
100,644 KB
testcase_10 AC 204 ms
100,576 KB
testcase_11 AC 205 ms
100,464 KB
testcase_12 AC 207 ms
100,472 KB
testcase_13 AC 138 ms
91,448 KB
testcase_14 AC 207 ms
100,720 KB
testcase_15 AC 71 ms
71,308 KB
testcase_16 AC 72 ms
71,648 KB
testcase_17 AC 204 ms
100,448 KB
testcase_18 AC 205 ms
100,604 KB
testcase_19 AC 204 ms
100,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n = ni()
a = na()
ans = 0
mod = 10**9+7
c = 1
for i in range(n):
    c*=a[i]
    c%=mod
    if i==n-1:
        ans+=c
    else:
        ans+=2*pow(3,n-i-2,mod)*c
    ans%=mod
print(ans)
0