結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ysys
提出日時 2019-03-15 22:03:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 20,184 KB
最終ジャッジ日時 2023-09-14 13:36:40
合計ジャッジ時間 8,855 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,912 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 195 ms
20,068 KB
testcase_04 AC 194 ms
20,008 KB
testcase_05 AC 191 ms
20,036 KB
testcase_06 AC 192 ms
20,116 KB
testcase_07 AC 188 ms
20,116 KB
testcase_08 AC 189 ms
19,988 KB
testcase_09 AC 194 ms
20,012 KB
testcase_10 AC 194 ms
20,068 KB
testcase_11 AC 189 ms
20,148 KB
testcase_12 AC 190 ms
20,184 KB
testcase_13 AC 192 ms
20,016 KB
testcase_14 AC 190 ms
20,136 KB
testcase_15 AC 195 ms
19,992 KB
testcase_16 AC 192 ms
20,044 KB
testcase_17 AC 192 ms
20,128 KB
testcase_18 AC 191 ms
20,032 KB
testcase_19 AC 191 ms
19,996 KB
testcase_20 AC 190 ms
19,996 KB
testcase_21 AC 190 ms
20,016 KB
testcase_22 AC 190 ms
20,032 KB
testcase_23 AC 141 ms
16,340 KB
testcase_24 AC 55 ms
11,648 KB
testcase_25 AC 122 ms
15,212 KB
testcase_26 AC 114 ms
14,656 KB
testcase_27 AC 186 ms
19,748 KB
testcase_28 AC 171 ms
18,544 KB
testcase_29 AC 38 ms
10,132 KB
testcase_30 AC 51 ms
10,480 KB
testcase_31 AC 141 ms
16,436 KB
testcase_32 AC 67 ms
11,756 KB
testcase_33 AC 116 ms
15,072 KB
testcase_34 AC 88 ms
12,988 KB
testcase_35 AC 192 ms
20,056 KB
testcase_36 AC 33 ms
9,356 KB
testcase_37 AC 170 ms
18,376 KB
testcase_38 AC 178 ms
19,188 KB
testcase_39 AC 116 ms
14,760 KB
testcase_40 AC 34 ms
9,308 KB
testcase_41 AC 44 ms
10,312 KB
testcase_42 AC 111 ms
14,616 KB
testcase_43 AC 16 ms
7,924 KB
testcase_44 AC 15 ms
7,784 KB
testcase_45 AC 16 ms
7,836 KB
testcase_46 AC 16 ms
7,928 KB
testcase_47 AC 16 ms
7,836 KB
testcase_48 AC 16 ms
7,936 KB
testcase_49 AC 16 ms
7,832 KB
testcase_50 AC 16 ms
7,956 KB
testcase_51 AC 15 ms
7,776 KB
testcase_52 AC 16 ms
7,840 KB
testcase_53 AC 16 ms
7,864 KB
testcase_54 AC 16 ms
7,840 KB
testcase_55 AC 16 ms
7,860 KB
testcase_56 AC 16 ms
7,908 KB
testcase_57 AC 16 ms
7,776 KB
testcase_58 AC 16 ms
7,768 KB
testcase_59 AC 16 ms
7,776 KB
testcase_60 AC 15 ms
7,836 KB
testcase_61 AC 16 ms
7,784 KB
testcase_62 AC 15 ms
7,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

rfact[n] = pow(fact[n], MOD - 2, MOD)
for i in range(n - 1, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(x, y):
    return fact[x] * rfact[x - y] * rfact[y] % MOD


num = 0
for i in range(n):
    num += comb(n - 1, i) * a[i]
    num %= MOD

print(num)
0