結果

問題 No.797 Noelちゃんとピラミッド
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-15 22:39:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 23,924 KB
最終ジャッジ日時 2023-09-14 13:53:38
合計ジャッジ時間 11,240 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,752 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
7,728 KB
testcase_03 AC 270 ms
23,800 KB
testcase_04 AC 265 ms
23,836 KB
testcase_05 AC 265 ms
23,796 KB
testcase_06 AC 269 ms
23,888 KB
testcase_07 AC 268 ms
23,740 KB
testcase_08 AC 267 ms
23,796 KB
testcase_09 AC 271 ms
23,724 KB
testcase_10 AC 269 ms
23,768 KB
testcase_11 AC 263 ms
23,836 KB
testcase_12 AC 271 ms
23,840 KB
testcase_13 AC 268 ms
23,892 KB
testcase_14 AC 265 ms
23,804 KB
testcase_15 AC 264 ms
23,724 KB
testcase_16 AC 266 ms
23,820 KB
testcase_17 AC 270 ms
23,828 KB
testcase_18 AC 267 ms
23,844 KB
testcase_19 AC 266 ms
23,924 KB
testcase_20 AC 270 ms
23,768 KB
testcase_21 AC 266 ms
23,796 KB
testcase_22 AC 264 ms
23,844 KB
testcase_23 AC 195 ms
19,248 KB
testcase_24 AC 70 ms
11,580 KB
testcase_25 AC 165 ms
17,552 KB
testcase_26 AC 159 ms
16,856 KB
testcase_27 AC 264 ms
23,280 KB
testcase_28 AC 232 ms
21,908 KB
testcase_29 AC 47 ms
10,304 KB
testcase_30 AC 68 ms
11,192 KB
testcase_31 AC 192 ms
19,332 KB
testcase_32 AC 88 ms
12,656 KB
testcase_33 AC 158 ms
17,192 KB
testcase_34 AC 116 ms
14,432 KB
testcase_35 AC 264 ms
23,788 KB
testcase_36 AC 41 ms
9,688 KB
testcase_37 AC 231 ms
21,924 KB
testcase_38 AC 242 ms
22,428 KB
testcase_39 AC 158 ms
17,268 KB
testcase_40 AC 42 ms
9,564 KB
testcase_41 AC 55 ms
10,596 KB
testcase_42 AC 153 ms
16,608 KB
testcase_43 AC 16 ms
7,840 KB
testcase_44 AC 16 ms
7,824 KB
testcase_45 AC 16 ms
7,896 KB
testcase_46 AC 16 ms
7,844 KB
testcase_47 AC 16 ms
7,888 KB
testcase_48 AC 16 ms
7,788 KB
testcase_49 AC 16 ms
7,784 KB
testcase_50 AC 17 ms
7,744 KB
testcase_51 AC 16 ms
7,936 KB
testcase_52 AC 16 ms
7,840 KB
testcase_53 AC 16 ms
7,820 KB
testcase_54 AC 17 ms
7,820 KB
testcase_55 AC 16 ms
7,816 KB
testcase_56 AC 16 ms
7,728 KB
testcase_57 AC 17 ms
7,816 KB
testcase_58 AC 16 ms
7,852 KB
testcase_59 AC 17 ms
7,884 KB
testcase_60 AC 16 ms
7,728 KB
testcase_61 AC 16 ms
7,748 KB
testcase_62 AC 16 ms
7,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
factorial = [1]
for n in range(1, N+1):
    factorial.append( factorial[n-1] * n % mod)

invFact = [0] * (N+1)
invFact[N] = pow(factorial[N], mod-2, mod)

for n in range(N-2+1, -1, -1):
    invFact[n] = invFact[n+1] * (n+1) % mod

def combi(n,m):
    try:
        return factorial[n] * invFact[m] * invFact[n-m] % mod
    except:
        print(n, m)

# print(factorial, invFact)
coeff = [0] * (N)
for i in range(N):
    # coeff[i] = combi( max(N-i-1, i) , N-1 - max(N-i-1,i))
    coeff[i]  =  factorial[N-1] * invFact[  max(N-i-1, i) ] * invFact[ N-1 - max(N-i-1,i)]  % mod
    # print(i, max(N-i-1, i), N-1-max(N-i-1,i), coeff[i])

# print(coeff)
ans = 0

for i in range(N):
    ans = (ans + coeff[i] * A[i] % mod) % mod
print(ans)
0