結果

問題 No.741 AscNumber(Easy)
ユーザー kurimupykurimupy
提出日時 2020-06-15 15:55:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,384 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 172,880 KB
最終ジャッジ日時 2023-09-16 10:28:22
合計ジャッジ時間 19,804 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 16 ms
7,900 KB
testcase_02 AC 16 ms
7,860 KB
testcase_03 AC 16 ms
7,852 KB
testcase_04 AC 16 ms
7,776 KB
testcase_05 AC 16 ms
7,832 KB
testcase_06 AC 15 ms
7,920 KB
testcase_07 AC 16 ms
7,776 KB
testcase_08 AC 15 ms
7,788 KB
testcase_09 AC 16 ms
7,848 KB
testcase_10 AC 15 ms
7,928 KB
testcase_11 AC 15 ms
7,780 KB
testcase_12 AC 15 ms
7,808 KB
testcase_13 AC 15 ms
7,976 KB
testcase_14 AC 16 ms
7,844 KB
testcase_15 AC 15 ms
7,832 KB
testcase_16 AC 16 ms
7,972 KB
testcase_17 AC 16 ms
7,856 KB
testcase_18 AC 16 ms
7,936 KB
testcase_19 AC 15 ms
7,856 KB
testcase_20 AC 16 ms
8,416 KB
testcase_21 AC 16 ms
7,956 KB
testcase_22 AC 17 ms
8,348 KB
testcase_23 AC 16 ms
8,240 KB
testcase_24 AC 16 ms
7,856 KB
testcase_25 AC 16 ms
7,952 KB
testcase_26 AC 16 ms
8,216 KB
testcase_27 AC 16 ms
7,976 KB
testcase_28 AC 15 ms
7,856 KB
testcase_29 AC 15 ms
7,812 KB
testcase_30 AC 16 ms
8,348 KB
testcase_31 AC 16 ms
8,232 KB
testcase_32 AC 16 ms
7,856 KB
testcase_33 AC 16 ms
8,376 KB
testcase_34 AC 16 ms
8,212 KB
testcase_35 AC 1,355 ms
165,224 KB
testcase_36 AC 537 ms
76,624 KB
testcase_37 AC 661 ms
88,852 KB
testcase_38 AC 651 ms
87,532 KB
testcase_39 AC 521 ms
75,308 KB
testcase_40 AC 722 ms
99,508 KB
testcase_41 AC 1,179 ms
151,556 KB
testcase_42 AC 581 ms
84,020 KB
testcase_43 AC 412 ms
63,060 KB
testcase_44 AC 910 ms
120,372 KB
testcase_45 AC 964 ms
129,116 KB
testcase_46 AC 1,214 ms
157,524 KB
testcase_47 AC 176 ms
33,436 KB
testcase_48 AC 1,200 ms
157,636 KB
testcase_49 AC 1,052 ms
133,104 KB
testcase_50 AC 125 ms
25,072 KB
testcase_51 AC 425 ms
65,704 KB
testcase_52 AC 1,384 ms
172,880 KB
testcase_53 AC 1,382 ms
172,876 KB
testcase_54 AC 1,376 ms
171,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#コンビネーションクラスの作成
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


N = int(input())
c = Combi(N+10, 10**9+7)
ans = c.combi(N+9, 9)
print(ans)

0