結果

問題 No.1681 +-*
ユーザー tcltktcltk
提出日時 2021-09-18 13:16:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 338 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 125,052 KB
最終ジャッジ日時 2023-09-12 23:22:03
合計ジャッジ時間 7,653 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
89,196 KB
testcase_01 AC 200 ms
89,248 KB
testcase_02 AC 205 ms
89,300 KB
testcase_03 AC 205 ms
89,592 KB
testcase_04 AC 205 ms
89,328 KB
testcase_05 AC 322 ms
121,400 KB
testcase_06 AC 320 ms
121,268 KB
testcase_07 AC 325 ms
121,492 KB
testcase_08 AC 331 ms
125,012 KB
testcase_09 AC 331 ms
125,044 KB
testcase_10 AC 330 ms
125,024 KB
testcase_11 AC 331 ms
125,028 KB
testcase_12 AC 329 ms
124,844 KB
testcase_13 AC 270 ms
107,240 KB
testcase_14 AC 331 ms
124,988 KB
testcase_15 AC 204 ms
89,544 KB
testcase_16 AC 203 ms
89,584 KB
testcase_17 AC 333 ms
125,016 KB
testcase_18 AC 337 ms
125,052 KB
testcase_19 AC 338 ms
124,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """3
# 1 2 3
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

MOD = 1000000007

N = int(input())
A = list(map(int, input().split()))

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