結果

問題 No.741 AscNumber(Easy)
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-12-12 21:52:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 418 ms / 2,000 ms
コード長 1,292 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 86,632 KB
最終ジャッジ日時 2023-09-28 15:23:15
合計ジャッジ時間 8,107 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,136 KB
testcase_01 AC 17 ms
8,220 KB
testcase_02 AC 16 ms
8,136 KB
testcase_03 AC 17 ms
8,228 KB
testcase_04 AC 16 ms
8,204 KB
testcase_05 AC 16 ms
8,176 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 17 ms
8,080 KB
testcase_08 AC 16 ms
8,080 KB
testcase_09 AC 16 ms
8,224 KB
testcase_10 AC 16 ms
8,228 KB
testcase_11 AC 17 ms
8,092 KB
testcase_12 AC 16 ms
8,152 KB
testcase_13 AC 16 ms
8,080 KB
testcase_14 AC 16 ms
8,336 KB
testcase_15 AC 17 ms
8,340 KB
testcase_16 AC 17 ms
8,308 KB
testcase_17 AC 16 ms
8,304 KB
testcase_18 AC 17 ms
8,220 KB
testcase_19 AC 16 ms
8,160 KB
testcase_20 AC 17 ms
8,260 KB
testcase_21 AC 16 ms
8,276 KB
testcase_22 AC 16 ms
8,188 KB
testcase_23 AC 16 ms
8,212 KB
testcase_24 AC 16 ms
8,184 KB
testcase_25 AC 16 ms
8,156 KB
testcase_26 AC 17 ms
8,216 KB
testcase_27 AC 16 ms
8,244 KB
testcase_28 AC 17 ms
8,168 KB
testcase_29 AC 16 ms
8,276 KB
testcase_30 AC 16 ms
8,140 KB
testcase_31 AC 16 ms
8,204 KB
testcase_32 AC 16 ms
8,168 KB
testcase_33 AC 17 ms
8,264 KB
testcase_34 AC 17 ms
8,396 KB
testcase_35 AC 399 ms
82,912 KB
testcase_36 AC 185 ms
40,764 KB
testcase_37 AC 213 ms
46,468 KB
testcase_38 AC 212 ms
45,944 KB
testcase_39 AC 181 ms
40,000 KB
testcase_40 AC 240 ms
51,544 KB
testcase_41 AC 366 ms
76,296 KB
testcase_42 AC 203 ms
44,428 KB
testcase_43 AC 151 ms
34,148 KB
testcase_44 AC 289 ms
61,432 KB
testcase_45 AC 313 ms
65,768 KB
testcase_46 AC 380 ms
79,192 KB
testcase_47 AC 79 ms
20,240 KB
testcase_48 AC 387 ms
79,248 KB
testcase_49 AC 322 ms
67,548 KB
testcase_50 AC 58 ms
16,284 KB
testcase_51 AC 160 ms
35,584 KB
testcase_52 AC 418 ms
86,560 KB
testcase_53 AC 415 ms
86,632 KB
testcase_54 AC 413 ms
85,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Combinatorics:
	def __init__(self, n: int, mod: int) -> None:
		self.n = n
		self.mod = mod
		self.fa = [1] * (self.n + 1)
		self.fi = [1] * (self.n + 1)

		for i in range(1, self.n + 1):
			self.fa[i] = self.fa[i - 1] * i % self.mod

		self.fi[-1] = pow(self.fa[-1], self.mod - 2, self.mod)

		for i in range(self.n, 0, -1):
			self.fi[i - 1] = self.fi[i] * i % self.mod

	def comb(self, n: int, r: int) -> int:
		if n < r:return 0
		if n < 0 or r < 0:return 0
		return self.fa[n] * self.fi[r] % self.mod * self.fi[n - r] % self.mod

	def perm(self, n: int, r: int) -> int:
		if n < r:return 0
		if n < 0 or r < 0:return 0
		return self.fa[n] * self.fi[n - r] % self.mod
		
	def combr(self, n: int, r: int) -> int:
		if n == r == 0:return 1
		return self.comb(n + r - 1, r)
"""
非負整数のうち、10進数表示をしたときに桁が昇順に並んでいるものをAscNumberと定義します。
例えば0, 1, 123, 12234, 334はAscNumberです。はAscNumberではありません。

正の整数が与えられるので、10^N未満のAscNumberがいくつあるかを求めてください。
ただし答えは大きくなるので、10 ** 9 + 7で割った余りを出力してください。
"""
n = int(input())
C = Combinatorics(n + 9, 10**9 + 7)
print(C.comb(n + 9, 9))
0