結果

問題 No.2141 Enumeratest
ユーザー MasKoaTSMasKoaTS
提出日時 2022-12-02 22:03:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 983 ms / 2,000 ms
コード長 2,435 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 83,584 KB
最終ジャッジ日時 2024-04-18 06:05:32
合計ジャッジ時間 5,602 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,480 KB
testcase_01 AC 43 ms
52,480 KB
testcase_02 AC 108 ms
76,672 KB
testcase_03 AC 93 ms
76,100 KB
testcase_04 AC 983 ms
83,584 KB
testcase_05 AC 43 ms
52,480 KB
testcase_06 AC 36 ms
52,992 KB
testcase_07 AC 56 ms
67,840 KB
testcase_08 AC 71 ms
75,904 KB
testcase_09 AC 68 ms
76,044 KB
testcase_10 AC 76 ms
75,904 KB
testcase_11 AC 90 ms
75,776 KB
testcase_12 AC 53 ms
63,104 KB
testcase_13 AC 65 ms
75,704 KB
testcase_14 AC 86 ms
75,844 KB
testcase_15 AC 76 ms
75,628 KB
testcase_16 AC 81 ms
75,776 KB
testcase_17 AC 59 ms
75,392 KB
testcase_18 AC 60 ms
75,496 KB
testcase_19 AC 63 ms
75,620 KB
testcase_20 AC 65 ms
75,740 KB
testcase_21 AC 65 ms
75,392 KB
testcase_22 AC 64 ms
75,748 KB
testcase_23 AC 66 ms
76,032 KB
testcase_24 AC 267 ms
77,424 KB
testcase_25 AC 96 ms
76,416 KB
testcase_26 AC 54 ms
61,952 KB
testcase_27 AC 68 ms
75,684 KB
testcase_28 AC 67 ms
75,340 KB
testcase_29 AC 59 ms
74,112 KB
testcase_30 AC 72 ms
75,476 KB
testcase_31 AC 66 ms
75,520 KB
testcase_32 AC 65 ms
75,392 KB
testcase_33 AC 68 ms
75,520 KB
testcase_34 AC 598 ms
80,472 KB
testcase_35 AC 53 ms
63,616 KB
testcase_36 AC 67 ms
75,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

class ModInt:
	mod = 998244353

	def __init__(self, x):
		self.x = x % ModInt.mod

	@classmethod
	def set_mod(cls, mod: int) -> None:
		ModInt.mod = mod
		
	def __str__(self):
		return str(self.x)

	__repr__ = __str__

	def __add__(self, other):
		return (ModInt(self.x + other.x) if isinstance(other, ModInt) else ModInt(self.x + other))

	def __sub__(self, other):
		return (ModInt(self.x - other.x) if isinstance(other, ModInt) else ModInt(self.x - other))

	def __mul__(self, other):
		return (ModInt(self.x * other.x) if isinstance(other, ModInt) else ModInt(self.x * other))

	def __truediv__(self, other):
		return (ModInt(self.x * pow(other.x, ModInt.mod - 2, ModInt.mod)) if isinstance(other, ModInt)
		  else ModInt(self.x * pow(other, ModInt.mod - 2, ModInt.mod)))

	def __pow__(self, other):
		return ModInt(pow(self.x, other.x, ModInt.mod)) if isinstance(other, ModInt) else ModInt(pow(self.x, other, ModInt.mod))

	__radd__ = __add__

	def __rsub__(self, other):
		return (ModInt(other.x - self.x) if isinstance(other, ModInt) else ModInt(other - self.x))

	__rmul__ = __mul__

	def __rtruediv__(self, other):
		return (ModInt(other.x * pow(self.x, ModInt.mod - 2, ModInt.mod)) if isinstance(other, ModInt)
		  else ModInt(other * pow(self.x, ModInt.mod - 2, ModInt.mod)))

	def __rpow__(self, other):
		return ModInt(pow(other.x, self.x, ModInt.mod)) if isinstance(other, ModInt) else ModInt(pow(other, self.x, ModInt.mod))

	def __iadd__(self, other):
		self = self + other
		return self

	def __isub__(self, other):
		self = self - other
		return self

	def __imul__(self, other):
		self = self * other
		return self

	def __itruediv__(self, other):
		self = self / other
		return self
	
	@classmethod
	def nCk(cls, n, k):
		if(isinstance(n, ModInt)):
			n = n.x
		if(isinstance(k, ModInt)):
			k = k.x
		r = min(n - k, k)
		ret = ModInt(1)
		for i in range(n - r + 1, n + 1):
			ret *= i
		d = ModInt(1)
		for i in range(2, r + 1):
			d *= i
		ret /= d
		return ret

"""
Main Code
"""

n, m = map(int, input().split())

if(n > m):
	ans = ModInt(1)
	for i in range(2, m + 1):
		ans *= i
	print(ans)
	exit(0)

a = [0] * n
t = m
i = 0
while(t > 0):
	a[i % n] += 1
	t -= 1
	i += 1
# print(a)

ans = ModInt(1)
for i in range(2, m + 1):
	ans *= i
fact = {}
for k in a:
	if(k not in fact):
		d = ModInt(1)
		for j in range(2, k + 1):
			d *= j
		fact[k] = d
	ans /= fact[k]
print(ans)
0