結果

問題 No.1681 +-*
ユーザー ああいいああいい
提出日時 2021-12-03 22:34:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 370 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,536 KB
実行使用メモリ 30,004 KB
最終ジャッジ日時 2023-09-20 10:38:25
合計ジャッジ時間 6,013 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,968 KB
testcase_01 AC 17 ms
7,976 KB
testcase_02 AC 17 ms
7,832 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 16 ms
7,884 KB
testcase_05 AC 215 ms
29,844 KB
testcase_06 AC 208 ms
29,664 KB
testcase_07 AC 221 ms
29,808 KB
testcase_08 AC 244 ms
29,992 KB
testcase_09 AC 239 ms
29,872 KB
testcase_10 AC 244 ms
29,920 KB
testcase_11 AC 248 ms
29,896 KB
testcase_12 AC 241 ms
29,840 KB
testcase_13 AC 110 ms
19,132 KB
testcase_14 AC 211 ms
29,876 KB
testcase_15 AC 15 ms
7,780 KB
testcase_16 AC 15 ms
7,756 KB
testcase_17 AC 228 ms
30,004 KB
testcase_18 AC 222 ms
29,920 KB
testcase_19 AC 240 ms
29,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

inv = [0] * 4
inv[1] = 1
inv[2] = P - P // 2
inv[3] = P - P // 3 * inv[P % 3] % P
c = 1
for _ in range(N-2):
    c *= 3
    c %= P

now = A[0] * 2 * c % P
s = now
for i in range(2,N):
    now = now * inv[3] * A[i-1] % P
    s += now
    s %= P
now = now * inv[2] * A[N-1] % P
s += now
s %= P
print(s)
0