結果

問題 No.1681 +-*
ユーザー playerplayer
提出日時 2023-12-27 14:12:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 101,856 KB
最終ジャッジ日時 2023-12-27 14:12:58
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 42 ms
53,460 KB
testcase_05 AC 163 ms
101,768 KB
testcase_06 AC 160 ms
101,780 KB
testcase_07 AC 161 ms
101,768 KB
testcase_08 AC 177 ms
101,856 KB
testcase_09 AC 177 ms
101,856 KB
testcase_10 AC 184 ms
101,856 KB
testcase_11 AC 181 ms
101,856 KB
testcase_12 AC 177 ms
101,856 KB
testcase_13 AC 102 ms
85,344 KB
testcase_14 AC 175 ms
101,856 KB
testcase_15 AC 34 ms
53,460 KB
testcase_16 AC 34 ms
53,460 KB
testcase_17 AC 177 ms
101,856 KB
testcase_18 AC 186 ms
101,856 KB
testcase_19 AC 177 ms
101,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

ans = 0

# 全て*の場合を先に加算
num1 = 1
for i in range(n):
    num1 *= a[i]
    num1 %= mod
ans += num1

for i in range(n-1):
    if i == 0:
        former = a[i]
        tmp = 2*pow(3,n-i-2,mod)
        tmp %= mod
        ans += former*tmp
        ans %= mod
    else:
        former *= a[i]
        tmp = 2*pow(3,n-i-2,mod)
        tmp %= mod
        former %= mod
        ans += former*tmp
        ans %= mod

print(ans)
0