結果

問題 No.2245 Second Smallest
ユーザー shobonvipshobonvip
提出日時 2023-01-14 01:22:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 740 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 94,352 KB
最終ジャッジ日時 2023-08-30 03:27:47
合計ジャッジ時間 6,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
91,428 KB
testcase_01 AC 95 ms
91,748 KB
testcase_02 AC 97 ms
91,572 KB
testcase_03 AC 100 ms
91,624 KB
testcase_04 AC 98 ms
91,556 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 95 ms
91,640 KB
testcase_08 AC 95 ms
91,592 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# TLE AND RE
# O(H*W + K)

mod = 998244353
N = 10**6 + 5
fact = [1]*(N+1)
factinv = [1]*(N+1)

for i in range(2, N+1):
	fact[i] = fact[i-1] * i % mod

factinv[-1] = pow(fact[-1], mod-2, mod)
for i in range(N-1, 1, -1):
	factinv[i] = factinv[i+1] * (i+1) % mod

def cmb(a, b):
	if (a < b) or (b < 0):
		return 0
	return fact[a] * factinv[b] % mod * factinv[a-b] % mod

h,w,k = map(int,input().split())
l = [0] * (min(h,w) + 2)

for a in range(1, min(h,w)+1):
	l[a] = cmb(h,a) * cmb(w,a) % mod * fact[a] % mod * fact[h*w-a] % mod

#print(l)

ans = 0
for a in range(2, min(h,w)+2):
	ans += (l[a-1] - l[a]) * a % mod * cmb(h*w,a) % mod * fact[a+k-1] % mod * fact[h*w-a] % mod * factinv[h*w+k] % mod
	#print(ans)

print(ans * factinv[h*w] % mod)
0