結果

問題 No.1681 +-*
ユーザー stng
提出日時 2021-09-18 09:26:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 96,192 KB
最終ジャッジ日時 2024-06-30 06:05:56
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = [int(i) for i in input().split()]

mod = 10**9+7

ans = 0
ans += a[0]*(2*pow(3, n-2, mod))%mod
ans %= mod
kk = a[0]

for i in range(1,n):
    kk *= a[i]
    kk %= mod
    if i == n-1:
        ans += kk
        ans %= mod
        break
    ans += kk*(2*pow(3,n-i-2,mod))
    ans %= mod
    
print(ans)
0