結果

問題 No.1693 Invasion
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-10-10 17:01:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,101 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 11,056 KB
実行使用メモリ 24,800 KB
最終ジャッジ日時 2023-10-12 13:25:11
合計ジャッジ時間 15,691 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,752 KB
testcase_01 AC 15 ms
8,272 KB
testcase_02 AC 16 ms
8,380 KB
testcase_03 AC 18 ms
8,312 KB
testcase_04 AC 16 ms
8,352 KB
testcase_05 AC 22 ms
8,324 KB
testcase_06 AC 21 ms
8,348 KB
testcase_07 AC 22 ms
8,328 KB
testcase_08 AC 22 ms
8,396 KB
testcase_09 TLE -
testcase_10 AC 1,435 ms
24,448 KB
testcase_11 AC 475 ms
15,492 KB
testcase_12 AC 1,683 ms
24,800 KB
testcase_13 AC 813 ms
13,628 KB
testcase_14 AC 1,078 ms
14,760 KB
testcase_15 AC 620 ms
11,260 KB
testcase_16 AC 1,584 ms
15,176 KB
testcase_17 AC 16 ms
8,444 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

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