結果

問題 No.1681 +-*
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2021-09-17 22:28:54
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 30,048 KB
最終ジャッジ日時 2023-09-12 08:23:01
合計ジャッジ時間 4,056 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 15 ms
7,856 KB
testcase_02 AC 17 ms
7,916 KB
testcase_03 AC 16 ms
7,916 KB
testcase_04 AC 16 ms
7,864 KB
testcase_05 AC 188 ms
29,796 KB
testcase_06 AC 186 ms
29,736 KB
testcase_07 AC 191 ms
29,904 KB
testcase_08 AC 223 ms
29,884 KB
testcase_09 AC 217 ms
29,968 KB
testcase_10 AC 221 ms
29,972 KB
testcase_11 AC 225 ms
29,916 KB
testcase_12 AC 221 ms
29,972 KB
testcase_13 AC 101 ms
19,200 KB
testcase_14 AC 191 ms
30,048 KB
testcase_15 AC 15 ms
7,968 KB
testcase_16 AC 15 ms
7,852 KB
testcase_17 AC 204 ms
29,984 KB
testcase_18 AC 203 ms
30,016 KB
testcase_19 AC 229 ms
29,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))
inv_3 = pow(3,mod-2,mod)
ans = 0
tmp = 2*pow(3,N-2,mod)*A[0]
ans += tmp
ans %= mod

for i in range(1,N):
    tmp *= A[i]
    if i < N-1:
        tmp *= inv_3
    else:
        tmp *= pow(2,mod-2,mod)
    tmp %= mod
    ans += tmp
    ans %= mod
print(ans)
0