結果

問題 No.2467 Sum of Product of Binomial Coefficients
ユーザー fiblonariafiblonaria
提出日時 2023-09-21 19:21:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 528 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 78,760 KB
最終ジャッジ日時 2023-09-21 19:21:50
合計ジャッジ時間 4,130 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
76,640 KB
testcase_01 AC 262 ms
77,292 KB
testcase_02 AC 271 ms
76,980 KB
testcase_03 AC 261 ms
77,040 KB
testcase_04 AC 283 ms
77,228 KB
testcase_05 AC 528 ms
78,760 KB
testcase_06 AC 233 ms
77,668 KB
testcase_07 AC 140 ms
77,792 KB
testcase_08 AC 260 ms
77,732 KB
testcase_09 AC 329 ms
78,124 KB
testcase_10 AC 141 ms
77,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class mod_int: #素数を法とした自然数, または有理数を扱うことのできるクラス
	def __init__(self, value, mod):
		self.value = value % mod
		self.mod = mod
	def __neg__(self):
		return mod_int(-self.value, self.mod)
	def __add__(self, other):
		if type(other) == mod_int:
			return mod_int(self.value + other.value, self.mod)
		elif type(other) == int:
			return mod_int(self.value + other, self.mod)
		raise TypeError()
	def __sub__(self, other):
		return self + (-other)
	def __mul__(self, other):
		if type(other) == mod_int:
			return mod_int(self.value * other.value, self.mod)
		elif type(other) == int:
			return mod_int(self.value * other, self.mod)
		raise TypeError()
	def __truediv__(self, other):
		if type(other) in [mod_int, int]:
			return self * other ** (self.mod - 2)
		raise TypeError()
	def __pow__(self, other):
		if type(other) != int:
			raise TypeError()
		cur, ret = self.value, 1
		while other > 0:
			if other % 2:
				ret = (ret * cur) % self.mod
			other //= 2
			cur = (cur ** 2) % self.mod
		return mod_int(ret, self.mod)
	def __repr__(self):
		return str(self.value)
T = int(input())
mod = 998244353
for i in range(T):
	N, K = map(int, input().split())
	temp = mod_int(1, mod)
	one = mod_int(1, mod)
	ans = mod_int(0, mod)
	for i in range(K):
		temp += one
		ans += temp ** N
	print(ans)
0