結果

問題 No.797 Noelちゃんとピラミッド
ユーザー stngstng
提出日時 2022-07-02 10:58:31
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 107,272 KB
最終ジャッジ日時 2023-08-18 02:03:14
合計ジャッジ時間 10,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,128 KB
testcase_01 AC 73 ms
71,316 KB
testcase_02 AC 71 ms
71,120 KB
testcase_03 AC 137 ms
105,700 KB
testcase_04 AC 133 ms
105,564 KB
testcase_05 AC 134 ms
105,756 KB
testcase_06 AC 131 ms
105,976 KB
testcase_07 AC 133 ms
105,652 KB
testcase_08 AC 132 ms
105,764 KB
testcase_09 AC 134 ms
105,744 KB
testcase_10 AC 131 ms
105,768 KB
testcase_11 AC 131 ms
105,888 KB
testcase_12 AC 133 ms
105,704 KB
testcase_13 AC 132 ms
105,568 KB
testcase_14 AC 132 ms
105,500 KB
testcase_15 AC 135 ms
105,856 KB
testcase_16 AC 133 ms
105,888 KB
testcase_17 AC 131 ms
105,728 KB
testcase_18 AC 132 ms
105,568 KB
testcase_19 AC 136 ms
105,680 KB
testcase_20 AC 135 ms
105,936 KB
testcase_21 AC 133 ms
105,808 KB
testcase_22 AC 133 ms
105,964 KB
testcase_23 AC 120 ms
96,952 KB
testcase_24 AC 96 ms
80,408 KB
testcase_25 AC 114 ms
93,992 KB
testcase_26 AC 111 ms
91,816 KB
testcase_27 AC 133 ms
107,272 KB
testcase_28 AC 128 ms
103,112 KB
testcase_29 AC 89 ms
76,632 KB
testcase_30 AC 96 ms
80,180 KB
testcase_31 AC 119 ms
96,920 KB
testcase_32 AC 99 ms
83,476 KB
testcase_33 AC 113 ms
92,404 KB
testcase_34 AC 105 ms
86,476 KB
testcase_35 AC 139 ms
105,692 KB
testcase_36 AC 87 ms
76,544 KB
testcase_37 AC 127 ms
103,232 KB
testcase_38 AC 132 ms
104,160 KB
testcase_39 AC 112 ms
92,520 KB
testcase_40 AC 88 ms
76,600 KB
testcase_41 AC 92 ms
78,016 KB
testcase_42 AC 112 ms
91,840 KB
testcase_43 AC 75 ms
71,328 KB
testcase_44 AC 78 ms
71,324 KB
testcase_45 AC 74 ms
71,340 KB
testcase_46 AC 74 ms
71,460 KB
testcase_47 AC 71 ms
71,508 KB
testcase_48 AC 72 ms
71,420 KB
testcase_49 AC 72 ms
71,200 KB
testcase_50 AC 71 ms
71,208 KB
testcase_51 AC 73 ms
71,308 KB
testcase_52 AC 73 ms
71,324 KB
testcase_53 AC 72 ms
71,224 KB
testcase_54 AC 70 ms
71,180 KB
testcase_55 AC 71 ms
71,036 KB
testcase_56 AC 71 ms
70,988 KB
testcase_57 AC 72 ms
71,308 KB
testcase_58 AC 70 ms
71,324 KB
testcase_59 AC 71 ms
71,208 KB
testcase_60 AC 72 ms
70,988 KB
testcase_61 AC 73 ms
71,304 KB
testcase_62 AC 72 ms
71,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
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 )

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

print(ans)
0