結果

問題 No.1081 和の和
ユーザー nephrologistnephrologist
提出日時 2020-06-19 21:27:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-09-16 13:17:34
合計ジャッジ時間 867 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,836 KB
testcase_01 AC 16 ms
7,796 KB
testcase_02 AC 15 ms
7,784 KB
testcase_03 AC 15 ms
7,892 KB
testcase_04 AC 16 ms
7,788 KB
testcase_05 AC 15 ms
7,784 KB
testcase_06 AC 15 ms
7,720 KB
testcase_07 AC 16 ms
7,864 KB
testcase_08 AC 17 ms
7,772 KB
testcase_09 AC 16 ms
7,776 KB
testcase_10 AC 16 ms
7,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
N = n + 5
bikkuri = [0 for i in range(N)]
bikkuri[0] = 1
gyaku = [0 for i in range(N)]
gyaku[0] = 1
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
    gyaku[i] = pow(bikkuri[i], mod - 2, mod)


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


temp = 0
for i in range(n):
    temp += comb(n - 1, i) * A[i]
    temp %= mod
print(temp)
0