結果

問題 No.797 Noelちゃんとピラミッド
ユーザー TakoKurageTakoKurage
提出日時 2019-03-15 22:01:35
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 25,652 KB
最終ジャッジ日時 2023-09-14 13:35:29
合計ジャッジ時間 11,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 15 ms
7,768 KB
testcase_02 AC 16 ms
7,736 KB
testcase_03 AC 241 ms
25,504 KB
testcase_04 AC 240 ms
25,392 KB
testcase_05 AC 251 ms
25,572 KB
testcase_06 AC 253 ms
25,560 KB
testcase_07 AC 239 ms
25,300 KB
testcase_08 AC 241 ms
25,420 KB
testcase_09 AC 248 ms
25,400 KB
testcase_10 AC 243 ms
25,312 KB
testcase_11 AC 244 ms
25,396 KB
testcase_12 AC 248 ms
25,320 KB
testcase_13 AC 246 ms
25,652 KB
testcase_14 AC 245 ms
25,420 KB
testcase_15 AC 246 ms
25,396 KB
testcase_16 AC 259 ms
25,304 KB
testcase_17 AC 252 ms
25,316 KB
testcase_18 AC 249 ms
25,560 KB
testcase_19 AC 255 ms
25,304 KB
testcase_20 AC 244 ms
25,316 KB
testcase_21 AC 248 ms
25,300 KB
testcase_22 AC 246 ms
25,248 KB
testcase_23 AC 180 ms
20,848 KB
testcase_24 AC 63 ms
11,756 KB
testcase_25 AC 144 ms
18,096 KB
testcase_26 AC 139 ms
18,264 KB
testcase_27 AC 244 ms
24,812 KB
testcase_28 AC 210 ms
22,588 KB
testcase_29 AC 43 ms
10,464 KB
testcase_30 AC 61 ms
11,780 KB
testcase_31 AC 173 ms
20,416 KB
testcase_32 AC 80 ms
13,352 KB
testcase_33 AC 145 ms
17,640 KB
testcase_34 AC 104 ms
15,244 KB
testcase_35 AC 248 ms
25,408 KB
testcase_36 AC 39 ms
9,948 KB
testcase_37 AC 215 ms
23,348 KB
testcase_38 AC 230 ms
24,212 KB
testcase_39 AC 143 ms
17,684 KB
testcase_40 AC 37 ms
9,752 KB
testcase_41 AC 50 ms
10,584 KB
testcase_42 AC 139 ms
17,876 KB
testcase_43 AC 16 ms
7,656 KB
testcase_44 AC 15 ms
7,832 KB
testcase_45 AC 15 ms
7,740 KB
testcase_46 AC 15 ms
7,740 KB
testcase_47 AC 16 ms
7,836 KB
testcase_48 AC 16 ms
7,880 KB
testcase_49 AC 16 ms
7,800 KB
testcase_50 AC 16 ms
7,744 KB
testcase_51 AC 15 ms
7,736 KB
testcase_52 AC 16 ms
7,744 KB
testcase_53 AC 16 ms
7,740 KB
testcase_54 AC 16 ms
7,856 KB
testcase_55 AC 16 ms
7,792 KB
testcase_56 AC 16 ms
7,788 KB
testcase_57 AC 15 ms
7,832 KB
testcase_58 AC 15 ms
7,844 KB
testcase_59 AC 16 ms
7,844 KB
testcase_60 AC 15 ms
7,740 KB
testcase_61 AC 16 ms
7,652 KB
testcase_62 AC 16 ms
7,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [int(i) for i in input().split()]

mod = 10 ** 9 + 7


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


result = 0
for i, ai in enumerate(A):
    result += ai * cmb(N - 1, i, mod) % mod

print(result % mod)
0