結果

問題 No.2381 Gift Exchange Party
ユーザー かつっぱ競プロかつっぱ競プロ
提出日時 2023-07-14 21:37:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 338 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 82,184 KB
最終ジャッジ日時 2023-10-14 11:39:51
合計ジャッジ時間 5,937 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
82,184 KB
testcase_01 AC 78 ms
77,652 KB
testcase_02 AC 78 ms
77,492 KB
testcase_03 AC 76 ms
77,592 KB
testcase_04 AC 77 ms
77,616 KB
testcase_05 AC 78 ms
77,644 KB
testcase_06 AC 77 ms
77,588 KB
testcase_07 AC 78 ms
77,604 KB
testcase_08 AC 77 ms
77,620 KB
testcase_09 AC 78 ms
77,640 KB
testcase_10 AC 78 ms
77,648 KB
testcase_11 AC 79 ms
77,512 KB
testcase_12 AC 77 ms
77,380 KB
testcase_13 AC 79 ms
77,620 KB
testcase_14 AC 93 ms
79,084 KB
testcase_15 AC 79 ms
77,544 KB
testcase_16 AC 77 ms
77,524 KB
testcase_17 AC 76 ms
77,472 KB
testcase_18 AC 78 ms
77,536 KB
testcase_19 AC 76 ms
77,544 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
fact = [1] * 220000

def inv(x):
    return pow(x, MOD-2, MOD)

for i in range(1, 220000):
    fact[i] = fact[i-1] * i % MOD

N, P = map(int, input().split())

C = 1

ans = 0

ans += C ## C0
for k in range(1, N//P + 1):
    C = C * fact[N - (k-1) * P] * inv(k * P * fact[N-k*P])
    ans += C

print((fact[N] - ans) % MOD)
0