結果

問題 No.1693 Invasion
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-10-10 17:01:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 1,101 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 80,384 KB
最終ジャッジ日時 2023-10-12 13:25:16
合計ジャッジ時間 3,935 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,120 KB
testcase_01 AC 70 ms
71,236 KB
testcase_02 AC 72 ms
71,092 KB
testcase_03 AC 76 ms
75,644 KB
testcase_04 AC 72 ms
71,120 KB
testcase_05 AC 79 ms
75,868 KB
testcase_06 AC 81 ms
75,880 KB
testcase_07 AC 79 ms
76,200 KB
testcase_08 AC 78 ms
76,252 KB
testcase_09 AC 147 ms
79,288 KB
testcase_10 AC 117 ms
80,048 KB
testcase_11 AC 99 ms
78,236 KB
testcase_12 AC 127 ms
80,280 KB
testcase_13 AC 106 ms
77,680 KB
testcase_14 AC 110 ms
78,164 KB
testcase_15 AC 102 ms
76,884 KB
testcase_16 AC 124 ms
78,204 KB
testcase_17 AC 71 ms
71,304 KB
testcase_18 AC 175 ms
80,384 KB
testcase_19 AC 89 ms
80,320 KB
testcase_20 AC 76 ms
75,892 KB
testcase_21 AC 171 ms
80,292 KB
testcase_22 AC 168 ms
80,312 KB
testcase_23 AC 168 ms
80,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

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

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

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

		for i in range(self.n * 2, 0, -1):
			self.fi[i - 1] = self.fi[i] * i % 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] % mod * self.fi[n - r] % 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] % mod
		
	def combr(self, n: int, r: int) -> int:
		if n == r == 0:return 1
		return self.comb(n + r - 1, r)
INF = 10 ** 18
n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [INF] * (m + 1)
dp[0] = 0
for i in range(m):
	for j in range(n):
		if i + a[j] <= m:
			dp[i + a[j]] = min(dp[i + a[j]], dp[i] + 1)
C = Combinatorics(m)
ans = 0
for i in range(m + 1):
	if dp[i] != INF: ans += C.comb(m - dp[i], i - dp[i]); ans %= mod
print(ans)
0