結果

問題 No.1681 +-*
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-09-17 23:17:46
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 105,980 KB
最終ジャッジ日時 2023-09-12 09:20:42
合計ジャッジ時間 5,867 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,392 KB
testcase_01 AC 75 ms
71,400 KB
testcase_02 AC 71 ms
71,376 KB
testcase_03 AC 74 ms
71,268 KB
testcase_04 AC 73 ms
71,464 KB
testcase_05 AC 259 ms
105,964 KB
testcase_06 AC 248 ms
105,956 KB
testcase_07 AC 246 ms
105,980 KB
testcase_08 AC 263 ms
100,472 KB
testcase_09 AC 260 ms
100,664 KB
testcase_10 AC 261 ms
100,300 KB
testcase_11 AC 263 ms
100,520 KB
testcase_12 AC 263 ms
100,660 KB
testcase_13 AC 165 ms
91,704 KB
testcase_14 AC 263 ms
100,512 KB
testcase_15 AC 71 ms
71,396 KB
testcase_16 AC 71 ms
71,448 KB
testcase_17 AC 264 ms
100,656 KB
testcase_18 AC 261 ms
100,560 KB
testcase_19 AC 263 ms
100,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10 ** 9 + 7
buf = pow(3,n-1,mod) * pow(3,mod-2,mod) * 2
buf2 = 1
for i in range(n):
    buf2 *= a[i]
    buf2 %= mod
    if i == 0:
        ans += buf * buf2
#         print(ans,"a")
    elif i != n - 1:
        buf *= pow(3,mod-2,mod)
        buf %= mod
        ans += buf * buf2
        ans %= mod
    else:
        ans += buf2
        ans %= mod
#     print(ans)
print(ans)
0