結果

問題 No.797 Noelちゃんとピラミッド
ユーザー uni745euni745e
提出日時 2019-03-17 05:49:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 19,968 KB
最終ジャッジ日時 2023-09-19 06:47:56
合計ジャッジ時間 17,644 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,944 KB
testcase_01 AC 18 ms
7,920 KB
testcase_02 AC 17 ms
7,760 KB
testcase_03 AC 425 ms
19,804 KB
testcase_04 AC 428 ms
19,860 KB
testcase_05 AC 429 ms
19,812 KB
testcase_06 AC 428 ms
19,928 KB
testcase_07 AC 424 ms
19,968 KB
testcase_08 AC 425 ms
19,808 KB
testcase_09 AC 427 ms
19,860 KB
testcase_10 AC 428 ms
19,816 KB
testcase_11 AC 429 ms
19,812 KB
testcase_12 AC 427 ms
19,820 KB
testcase_13 AC 429 ms
19,836 KB
testcase_14 AC 426 ms
19,872 KB
testcase_15 AC 426 ms
19,836 KB
testcase_16 AC 426 ms
19,820 KB
testcase_17 AC 428 ms
19,888 KB
testcase_18 AC 428 ms
19,868 KB
testcase_19 AC 428 ms
19,772 KB
testcase_20 AC 425 ms
19,804 KB
testcase_21 AC 424 ms
19,888 KB
testcase_22 AC 427 ms
19,836 KB
testcase_23 AC 307 ms
16,428 KB
testcase_24 AC 107 ms
11,476 KB
testcase_25 AC 262 ms
15,248 KB
testcase_26 AC 247 ms
14,872 KB
testcase_27 AC 417 ms
19,752 KB
testcase_28 AC 378 ms
18,264 KB
testcase_29 AC 69 ms
10,152 KB
testcase_30 AC 100 ms
10,560 KB
testcase_31 AC 307 ms
16,496 KB
testcase_32 AC 137 ms
11,700 KB
testcase_33 AC 254 ms
14,920 KB
testcase_34 AC 183 ms
12,932 KB
testcase_35 AC 427 ms
19,944 KB
testcase_36 AC 58 ms
9,444 KB
testcase_37 AC 373 ms
18,272 KB
testcase_38 AC 390 ms
19,052 KB
testcase_39 AC 250 ms
14,784 KB
testcase_40 AC 58 ms
9,324 KB
testcase_41 AC 82 ms
10,252 KB
testcase_42 AC 243 ms
14,744 KB
testcase_43 AC 16 ms
7,796 KB
testcase_44 AC 17 ms
7,828 KB
testcase_45 AC 17 ms
7,740 KB
testcase_46 AC 16 ms
7,760 KB
testcase_47 AC 16 ms
7,800 KB
testcase_48 AC 17 ms
7,772 KB
testcase_49 AC 17 ms
7,768 KB
testcase_50 AC 17 ms
7,752 KB
testcase_51 AC 17 ms
7,752 KB
testcase_52 AC 17 ms
7,908 KB
testcase_53 AC 16 ms
7,692 KB
testcase_54 AC 16 ms
7,960 KB
testcase_55 AC 17 ms
7,760 KB
testcase_56 AC 17 ms
7,768 KB
testcase_57 AC 17 ms
7,740 KB
testcase_58 AC 16 ms
7,752 KB
testcase_59 AC 16 ms
7,780 KB
testcase_60 AC 16 ms
7,692 KB
testcase_61 AC 17 ms
7,692 KB
testcase_62 AC 17 ms
7,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    fac = [0] * n
    inv = [0] * n
    fac[0] = fac[1] = 1
    inv[0] = inv[1] = 1
    for i in range(2, n):
        fac[i] = (fac[i - 1] * i) % MOD
        inv[i] = pow(fac[i], MOD - 2, MOD)

    def cmb_mod(n, r):
        return (fac[n] * inv[n - r] * inv[r]) % MOD

    res = 0
    for i in range(n):
        res += A[i] * cmb_mod(n - 1, i)
        res %= MOD

    return res


print(main())
0