結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ttrttr
提出日時 2020-06-29 20:24:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 25,728 KB
最終ジャッジ日時 2023-09-26 11:19:51
合計ジャッジ時間 13,366 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,864 KB
testcase_01 AC 16 ms
7,748 KB
testcase_02 AC 15 ms
7,872 KB
testcase_03 AC 257 ms
25,516 KB
testcase_04 AC 255 ms
25,592 KB
testcase_05 AC 257 ms
25,724 KB
testcase_06 AC 258 ms
25,556 KB
testcase_07 AC 260 ms
25,580 KB
testcase_08 AC 255 ms
25,592 KB
testcase_09 AC 254 ms
25,708 KB
testcase_10 AC 253 ms
25,604 KB
testcase_11 AC 250 ms
25,664 KB
testcase_12 AC 252 ms
25,696 KB
testcase_13 AC 250 ms
25,692 KB
testcase_14 AC 258 ms
25,520 KB
testcase_15 AC 258 ms
25,600 KB
testcase_16 AC 254 ms
25,472 KB
testcase_17 AC 258 ms
25,624 KB
testcase_18 AC 258 ms
25,576 KB
testcase_19 AC 259 ms
25,612 KB
testcase_20 AC 257 ms
25,728 KB
testcase_21 AC 254 ms
25,728 KB
testcase_22 AC 260 ms
25,512 KB
testcase_23 AC 186 ms
20,936 KB
testcase_24 AC 66 ms
11,796 KB
testcase_25 AC 153 ms
18,164 KB
testcase_26 AC 146 ms
17,588 KB
testcase_27 AC 247 ms
24,736 KB
testcase_28 AC 225 ms
23,028 KB
testcase_29 AC 45 ms
10,436 KB
testcase_30 AC 62 ms
11,700 KB
testcase_31 AC 183 ms
20,444 KB
testcase_32 AC 84 ms
13,452 KB
testcase_33 AC 152 ms
18,148 KB
testcase_34 AC 113 ms
15,208 KB
testcase_35 AC 259 ms
25,540 KB
testcase_36 AC 39 ms
9,980 KB
testcase_37 AC 222 ms
23,508 KB
testcase_38 AC 234 ms
23,796 KB
testcase_39 AC 149 ms
17,712 KB
testcase_40 AC 38 ms
9,860 KB
testcase_41 AC 53 ms
10,772 KB
testcase_42 AC 150 ms
17,980 KB
testcase_43 AC 15 ms
7,896 KB
testcase_44 AC 15 ms
7,832 KB
testcase_45 AC 15 ms
7,792 KB
testcase_46 AC 15 ms
7,860 KB
testcase_47 AC 15 ms
7,712 KB
testcase_48 AC 16 ms
7,920 KB
testcase_49 AC 16 ms
7,740 KB
testcase_50 AC 16 ms
7,836 KB
testcase_51 AC 16 ms
7,820 KB
testcase_52 AC 16 ms
7,864 KB
testcase_53 AC 16 ms
7,836 KB
testcase_54 AC 15 ms
7,724 KB
testcase_55 AC 16 ms
7,768 KB
testcase_56 AC 15 ms
7,788 KB
testcase_57 AC 16 ms
7,840 KB
testcase_58 AC 16 ms
7,840 KB
testcase_59 AC 15 ms
7,840 KB
testcase_60 AC 16 ms
7,740 KB
testcase_61 AC 15 ms
7,832 KB
testcase_62 AC 16 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [int(a) for a 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 )


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

print(ans)
0