結果

問題 No.797 Noelちゃんとピラミッド
ユーザー YamadaYamada
提出日時 2019-03-16 02:06:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 25,484 KB
最終ジャッジ日時 2023-09-14 15:00:22
合計ジャッジ時間 9,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,696 KB
testcase_01 AC 16 ms
7,788 KB
testcase_02 AC 15 ms
7,732 KB
testcase_03 AC 212 ms
25,072 KB
testcase_04 AC 222 ms
25,128 KB
testcase_05 AC 209 ms
25,040 KB
testcase_06 AC 210 ms
25,116 KB
testcase_07 AC 215 ms
25,096 KB
testcase_08 AC 211 ms
25,100 KB
testcase_09 AC 211 ms
25,380 KB
testcase_10 AC 212 ms
24,992 KB
testcase_11 AC 216 ms
25,200 KB
testcase_12 AC 206 ms
25,104 KB
testcase_13 AC 210 ms
25,176 KB
testcase_14 AC 215 ms
25,484 KB
testcase_15 AC 214 ms
25,084 KB
testcase_16 AC 211 ms
25,204 KB
testcase_17 AC 215 ms
25,068 KB
testcase_18 AC 213 ms
24,996 KB
testcase_19 AC 221 ms
25,396 KB
testcase_20 AC 210 ms
25,224 KB
testcase_21 AC 211 ms
25,460 KB
testcase_22 AC 215 ms
24,996 KB
testcase_23 AC 153 ms
20,436 KB
testcase_24 AC 57 ms
11,796 KB
testcase_25 AC 138 ms
18,696 KB
testcase_26 AC 122 ms
18,196 KB
testcase_27 AC 207 ms
25,116 KB
testcase_28 AC 184 ms
23,148 KB
testcase_29 AC 39 ms
10,412 KB
testcase_30 AC 55 ms
11,788 KB
testcase_31 AC 154 ms
20,732 KB
testcase_32 AC 71 ms
12,804 KB
testcase_33 AC 127 ms
18,624 KB
testcase_34 AC 95 ms
15,200 KB
testcase_35 AC 208 ms
25,352 KB
testcase_36 AC 34 ms
9,848 KB
testcase_37 AC 187 ms
23,484 KB
testcase_38 AC 196 ms
23,820 KB
testcase_39 AC 124 ms
17,416 KB
testcase_40 AC 35 ms
10,000 KB
testcase_41 AC 46 ms
10,996 KB
testcase_42 AC 122 ms
17,952 KB
testcase_43 AC 16 ms
7,864 KB
testcase_44 AC 15 ms
7,764 KB
testcase_45 AC 17 ms
7,820 KB
testcase_46 AC 17 ms
7,776 KB
testcase_47 AC 16 ms
7,820 KB
testcase_48 AC 16 ms
7,764 KB
testcase_49 AC 15 ms
7,800 KB
testcase_50 AC 16 ms
7,696 KB
testcase_51 AC 15 ms
7,740 KB
testcase_52 AC 15 ms
7,724 KB
testcase_53 AC 16 ms
7,856 KB
testcase_54 AC 15 ms
7,748 KB
testcase_55 AC 16 ms
7,816 KB
testcase_56 AC 16 ms
7,760 KB
testcase_57 AC 16 ms
7,732 KB
testcase_58 AC 15 ms
7,816 KB
testcase_59 AC 16 ms
7,896 KB
testcase_60 AC 15 ms
7,800 KB
testcase_61 AC 15 ms
7,824 KB
testcase_62 AC 15 ms
7,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

mod = 10**9+7
g1 =[1,1] #i番目=i!の元
g2 =[1,1] #i番目=i!の逆元
inverse =[0,1] #i番目=iの逆元

for i in range(2,N+1):
    g1.append(g1[-1]*i %mod) #i!の元の追加
    inverse.append(-inverse[mod % i] * (mod//i) % mod) #???(iの逆元を計算してるはず)
    g2.append((g2[-1]*inverse[-1])%mod)

ans = 0
for i in range((N+1)//2):
    a =A[i] +A[N-1-i]
    ans += a * cmb(N-1,i,mod) % mod
if N%2==1:
    n = N//2
    ans -= A[n] * cmb(N-1,n,mod) % mod

print(ans%mod)
0