結果

問題 No.797 Noelちゃんとピラミッド
ユーザー htkbhtkb
提出日時 2019-03-15 21:36:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 878 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 20,644 KB
最終ジャッジ日時 2023-09-14 13:09:00
合計ジャッジ時間 6,904 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,844 KB
testcase_01 AC 16 ms
7,836 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 129 ms
20,456 KB
testcase_04 AC 128 ms
20,432 KB
testcase_05 AC 129 ms
20,568 KB
testcase_06 AC 132 ms
20,504 KB
testcase_07 AC 131 ms
20,504 KB
testcase_08 AC 130 ms
20,432 KB
testcase_09 AC 129 ms
20,644 KB
testcase_10 AC 132 ms
20,536 KB
testcase_11 AC 130 ms
20,572 KB
testcase_12 AC 131 ms
20,612 KB
testcase_13 AC 130 ms
20,620 KB
testcase_14 AC 130 ms
20,592 KB
testcase_15 AC 129 ms
20,640 KB
testcase_16 AC 129 ms
20,504 KB
testcase_17 AC 129 ms
20,512 KB
testcase_18 AC 130 ms
20,532 KB
testcase_19 AC 129 ms
20,400 KB
testcase_20 AC 129 ms
20,604 KB
testcase_21 AC 130 ms
20,508 KB
testcase_22 AC 128 ms
20,460 KB
testcase_23 AC 96 ms
16,884 KB
testcase_24 AC 40 ms
11,640 KB
testcase_25 AC 83 ms
15,792 KB
testcase_26 AC 78 ms
15,300 KB
testcase_27 AC 125 ms
20,580 KB
testcase_28 AC 114 ms
19,136 KB
testcase_29 AC 31 ms
10,328 KB
testcase_30 AC 38 ms
10,684 KB
testcase_31 AC 95 ms
16,968 KB
testcase_32 AC 48 ms
11,988 KB
testcase_33 AC 81 ms
15,492 KB
testcase_34 AC 61 ms
13,296 KB
testcase_35 AC 130 ms
20,504 KB
testcase_36 AC 28 ms
9,364 KB
testcase_37 AC 113 ms
18,948 KB
testcase_38 AC 120 ms
19,360 KB
testcase_39 AC 80 ms
15,404 KB
testcase_40 AC 27 ms
9,388 KB
testcase_41 AC 34 ms
10,360 KB
testcase_42 AC 76 ms
15,112 KB
testcase_43 AC 16 ms
7,768 KB
testcase_44 AC 16 ms
7,808 KB
testcase_45 AC 16 ms
7,836 KB
testcase_46 AC 16 ms
7,864 KB
testcase_47 AC 16 ms
7,864 KB
testcase_48 AC 16 ms
7,912 KB
testcase_49 AC 15 ms
7,740 KB
testcase_50 AC 16 ms
7,744 KB
testcase_51 AC 16 ms
7,820 KB
testcase_52 AC 16 ms
7,948 KB
testcase_53 AC 16 ms
7,868 KB
testcase_54 AC 16 ms
7,736 KB
testcase_55 AC 16 ms
7,820 KB
testcase_56 AC 16 ms
7,808 KB
testcase_57 AC 15 ms
7,736 KB
testcase_58 AC 15 ms
7,836 KB
testcase_59 AC 16 ms
7,816 KB
testcase_60 AC 16 ms
7,768 KB
testcase_61 AC 16 ms
7,744 KB
testcase_62 AC 16 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]

    def __init__(self, mod: int = 10**9+7, max_n: int = 10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append

        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)

        inv_append(pow(fac[-1], mod-2, mod))

        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)

        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

    def get_combination(self, n, r):
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod


if __name__ == "__main__":
    N = int(input())
    a = tuple(map(int, input().split()))
    mod = 10**9+7
    bigcomb = BigCombination(mod, N-1)
    getcomb = bigcomb.get_combination
    print(sum(getcomb(N-1, i)*v % mod for i, v in enumerate(a)) % mod)
0