結果

問題 No.741 AscNumber(Easy)
ユーザー kurimupykurimupy
提出日時 2020-06-15 15:55:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 170,852 KB
最終ジャッジ日時 2023-09-16 10:25:37
合計ジャッジ時間 8,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,224 KB
testcase_01 AC 72 ms
71,584 KB
testcase_02 AC 70 ms
71,200 KB
testcase_03 AC 69 ms
71,324 KB
testcase_04 AC 76 ms
71,088 KB
testcase_05 AC 71 ms
71,384 KB
testcase_06 AC 72 ms
71,368 KB
testcase_07 AC 71 ms
71,464 KB
testcase_08 AC 76 ms
71,240 KB
testcase_09 AC 73 ms
71,328 KB
testcase_10 AC 73 ms
71,244 KB
testcase_11 AC 72 ms
71,384 KB
testcase_12 AC 73 ms
71,272 KB
testcase_13 AC 72 ms
71,376 KB
testcase_14 AC 70 ms
71,412 KB
testcase_15 AC 70 ms
71,244 KB
testcase_16 AC 70 ms
71,268 KB
testcase_17 AC 72 ms
71,380 KB
testcase_18 AC 70 ms
71,380 KB
testcase_19 AC 72 ms
71,388 KB
testcase_20 AC 76 ms
71,380 KB
testcase_21 AC 73 ms
71,544 KB
testcase_22 AC 73 ms
71,380 KB
testcase_23 AC 74 ms
71,380 KB
testcase_24 AC 74 ms
71,276 KB
testcase_25 AC 71 ms
71,316 KB
testcase_26 AC 74 ms
71,584 KB
testcase_27 AC 73 ms
71,160 KB
testcase_28 AC 74 ms
71,380 KB
testcase_29 AC 74 ms
71,272 KB
testcase_30 AC 75 ms
71,376 KB
testcase_31 AC 75 ms
71,376 KB
testcase_32 AC 75 ms
71,340 KB
testcase_33 AC 73 ms
71,468 KB
testcase_34 AC 74 ms
71,240 KB
testcase_35 AC 247 ms
169,508 KB
testcase_36 AC 159 ms
118,376 KB
testcase_37 AC 162 ms
119,772 KB
testcase_38 AC 161 ms
119,940 KB
testcase_39 AC 129 ms
95,064 KB
testcase_40 AC 170 ms
120,252 KB
testcase_41 AC 218 ms
146,132 KB
testcase_42 AC 162 ms
119,768 KB
testcase_43 AC 125 ms
94,564 KB
testcase_44 AC 177 ms
121,348 KB
testcase_45 AC 207 ms
145,052 KB
testcase_46 AC 219 ms
146,420 KB
testcase_47 AC 112 ms
92,512 KB
testcase_48 AC 217 ms
146,624 KB
testcase_49 AC 208 ms
145,412 KB
testcase_50 AC 85 ms
77,156 KB
testcase_51 AC 123 ms
94,952 KB
testcase_52 AC 251 ms
170,852 KB
testcase_53 AC 249 ms
170,548 KB
testcase_54 AC 246 ms
170,436 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