結果

問題 No.797 Noelちゃんとピラミッド
ユーザー kurimupykurimupy
提出日時 2020-06-15 16:12:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 28,648 KB
最終ジャッジ日時 2023-09-16 10:27:52
合計ジャッジ時間 10,724 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 17 ms
7,880 KB
testcase_02 AC 17 ms
7,880 KB
testcase_03 AC 227 ms
28,464 KB
testcase_04 AC 223 ms
28,412 KB
testcase_05 AC 221 ms
28,472 KB
testcase_06 AC 220 ms
28,412 KB
testcase_07 AC 226 ms
28,492 KB
testcase_08 AC 223 ms
28,472 KB
testcase_09 AC 219 ms
28,464 KB
testcase_10 AC 225 ms
28,592 KB
testcase_11 AC 220 ms
28,648 KB
testcase_12 AC 224 ms
28,356 KB
testcase_13 AC 221 ms
28,356 KB
testcase_14 AC 222 ms
28,352 KB
testcase_15 AC 227 ms
28,360 KB
testcase_16 AC 222 ms
28,336 KB
testcase_17 AC 219 ms
28,484 KB
testcase_18 AC 222 ms
28,436 KB
testcase_19 AC 220 ms
28,284 KB
testcase_20 AC 220 ms
28,476 KB
testcase_21 AC 223 ms
28,408 KB
testcase_22 AC 224 ms
28,284 KB
testcase_23 AC 162 ms
22,708 KB
testcase_24 AC 59 ms
12,624 KB
testcase_25 AC 131 ms
20,412 KB
testcase_26 AC 127 ms
19,728 KB
testcase_27 AC 216 ms
28,284 KB
testcase_28 AC 200 ms
26,040 KB
testcase_29 AC 41 ms
10,724 KB
testcase_30 AC 58 ms
12,368 KB
testcase_31 AC 156 ms
22,824 KB
testcase_32 AC 74 ms
14,336 KB
testcase_33 AC 131 ms
20,036 KB
testcase_34 AC 97 ms
16,472 KB
testcase_35 AC 224 ms
28,356 KB
testcase_36 AC 36 ms
10,236 KB
testcase_37 AC 194 ms
25,832 KB
testcase_38 AC 205 ms
26,940 KB
testcase_39 AC 128 ms
19,836 KB
testcase_40 AC 36 ms
10,256 KB
testcase_41 AC 47 ms
11,416 KB
testcase_42 AC 124 ms
19,588 KB
testcase_43 AC 16 ms
7,852 KB
testcase_44 AC 16 ms
7,792 KB
testcase_45 AC 16 ms
7,776 KB
testcase_46 AC 16 ms
7,952 KB
testcase_47 AC 16 ms
7,780 KB
testcase_48 AC 16 ms
7,832 KB
testcase_49 AC 16 ms
7,904 KB
testcase_50 AC 16 ms
7,780 KB
testcase_51 AC 16 ms
7,876 KB
testcase_52 AC 16 ms
7,792 KB
testcase_53 AC 16 ms
7,924 KB
testcase_54 AC 16 ms
7,852 KB
testcase_55 AC 16 ms
7,828 KB
testcase_56 AC 16 ms
7,852 KB
testcase_57 AC 15 ms
7,848 KB
testcase_58 AC 16 ms
7,852 KB
testcase_59 AC 16 ms
7,852 KB
testcase_60 AC 16 ms
7,928 KB
testcase_61 AC 15 ms
7,816 KB
testcase_62 AC 16 ms
7,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
ans = 0
mod = 10**9 + 7
A = list(map(int, input().split()))


class Data():
    def __init__(self):
        self.power = 1
        self.rev = 1


class Combi():
    def __init__(self, N, mod):
        self.lists = [Data() for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.lists[i].power = ((self.lists[i-1].power)*i) % self.mod
        self.lists[N].rev = pow(self.lists[N].power, self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.lists[j-1].rev = ((self.lists[j].rev)*j) % self.mod

    def combi(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev)) % self.mod


c = Combi(N-1, mod)
for i in range(N):
    ans += A[i]*c.combi(N-1, i)
    ans %= mod
print(ans)

0