結果

問題 No.797 Noelちゃんとピラミッド
ユーザー neterukunneterukun
提出日時 2019-05-06 04:06:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 20,148 KB
最終ジャッジ日時 2023-09-08 18:24:26
合計ジャッジ時間 18,663 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 461 ms
20,048 KB
testcase_04 AC 452 ms
20,060 KB
testcase_05 AC 448 ms
20,060 KB
testcase_06 AC 454 ms
20,052 KB
testcase_07 AC 461 ms
20,012 KB
testcase_08 AC 460 ms
19,988 KB
testcase_09 AC 459 ms
20,148 KB
testcase_10 AC 454 ms
20,052 KB
testcase_11 AC 458 ms
20,144 KB
testcase_12 AC 460 ms
20,016 KB
testcase_13 AC 459 ms
20,052 KB
testcase_14 AC 459 ms
19,984 KB
testcase_15 AC 461 ms
19,948 KB
testcase_16 AC 463 ms
20,052 KB
testcase_17 AC 456 ms
20,092 KB
testcase_18 AC 457 ms
20,060 KB
testcase_19 AC 451 ms
20,060 KB
testcase_20 AC 456 ms
20,140 KB
testcase_21 AC 454 ms
20,028 KB
testcase_22 AC 456 ms
20,136 KB
testcase_23 AC 330 ms
16,380 KB
testcase_24 AC 115 ms
11,536 KB
testcase_25 AC 280 ms
15,216 KB
testcase_26 AC 262 ms
14,680 KB
testcase_27 AC 445 ms
19,724 KB
testcase_28 AC 409 ms
18,488 KB
testcase_29 AC 71 ms
10,152 KB
testcase_30 AC 106 ms
10,644 KB
testcase_31 AC 326 ms
16,564 KB
testcase_32 AC 145 ms
11,740 KB
testcase_33 AC 271 ms
14,976 KB
testcase_34 AC 194 ms
13,180 KB
testcase_35 AC 453 ms
20,092 KB
testcase_36 AC 61 ms
9,332 KB
testcase_37 AC 404 ms
18,416 KB
testcase_38 AC 420 ms
19,124 KB
testcase_39 AC 272 ms
14,804 KB
testcase_40 AC 60 ms
9,324 KB
testcase_41 AC 87 ms
10,276 KB
testcase_42 AC 262 ms
14,712 KB
testcase_43 AC 16 ms
7,848 KB
testcase_44 AC 16 ms
7,880 KB
testcase_45 AC 16 ms
7,824 KB
testcase_46 AC 16 ms
7,856 KB
testcase_47 AC 15 ms
7,784 KB
testcase_48 AC 16 ms
7,816 KB
testcase_49 AC 16 ms
7,864 KB
testcase_50 AC 16 ms
7,852 KB
testcase_51 AC 16 ms
7,736 KB
testcase_52 AC 15 ms
7,800 KB
testcase_53 AC 15 ms
7,860 KB
testcase_54 AC 15 ms
7,812 KB
testcase_55 AC 16 ms
7,776 KB
testcase_56 AC 16 ms
7,816 KB
testcase_57 AC 16 ms
7,864 KB
testcase_58 AC 16 ms
7,864 KB
testcase_59 AC 16 ms
7,852 KB
testcase_60 AC 15 ms
7,864 KB
testcase_61 AC 15 ms
7,972 KB
testcase_62 AC 16 ms
7,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#Combinationクラス
class Combination:

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    #i!を求める
    def factorial(self, i):
        return self.fact[i]

    #k!の逆元を求める
    def inverse_factorial(self, i):
        return self.inv_fact[i]
         
    #k_C_rを求める
    def combination(self, i, j):
        return (self.fact[i] * self.inv_fact[i - j] * self.inv_fact[j]) % self.MOD

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7
comb = Combination(n, MOD)
ans = 0
for i in range(n):
    ans += comb.combination(n-1, i) * a[i]
    ans %= MOD
print(ans)
0