結果

問題 No.1681 +-*
ユーザー asumo0729asumo0729
提出日時 2021-09-17 21:58:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 108,244 KB
最終ジャッジ日時 2023-09-12 07:26:09
合計ジャッジ時間 4,172 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,272 KB
testcase_01 AC 94 ms
71,488 KB
testcase_02 AC 96 ms
71,388 KB
testcase_03 AC 99 ms
71,588 KB
testcase_04 AC 97 ms
71,488 KB
testcase_05 AC 136 ms
105,628 KB
testcase_06 AC 134 ms
105,880 KB
testcase_07 AC 133 ms
105,644 KB
testcase_08 AC 142 ms
108,212 KB
testcase_09 AC 145 ms
107,888 KB
testcase_10 AC 144 ms
108,080 KB
testcase_11 AC 146 ms
108,216 KB
testcase_12 AC 144 ms
108,244 KB
testcase_13 AC 120 ms
91,236 KB
testcase_14 AC 141 ms
107,944 KB
testcase_15 AC 95 ms
71,556 KB
testcase_16 AC 93 ms
71,368 KB
testcase_17 AC 140 ms
108,172 KB
testcase_18 AC 141 ms
107,900 KB
testcase_19 AC 140 ms
108,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
import bisect

stdin=sys.stdin
sys.setrecursionlimit(10 ** 8)

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
eps = 1e-9
sortkey = itemgetter(0)
mod = 10 ** 9+ 7

###############################################################
N = ip()
A = lp()
ans = 0
## a1 +- a2...

now = 1
p = pow(3, N - 1, mod)
q = pow(3, mod - 2, mod)

for i in range(N - 1):
    now *= A[i]
    now %= mod
    p *= q
    p %= mod
    ans += now * 2 * p
    ans %= mod
ans += now * A[-1]
ans %= mod
print(ans)
0