結果

問題 No.2381 Gift Exchange Party
ユーザー かつっぱ競プロかつっぱ競プロ
提出日時 2023-07-14 21:36:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 338 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 22,476 KB
最終ジャッジ日時 2023-10-14 11:39:16
合計ジャッジ時間 6,175 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
20,840 KB
testcase_01 AC 91 ms
16,504 KB
testcase_02 AC 89 ms
16,632 KB
testcase_03 AC 90 ms
16,428 KB
testcase_04 AC 87 ms
16,480 KB
testcase_05 AC 89 ms
16,520 KB
testcase_06 AC 92 ms
16,492 KB
testcase_07 AC 88 ms
16,620 KB
testcase_08 AC 90 ms
16,524 KB
testcase_09 AC 90 ms
16,568 KB
testcase_10 AC 92 ms
16,496 KB
testcase_11 AC 88 ms
16,572 KB
testcase_12 AC 89 ms
16,528 KB
testcase_13 AC 97 ms
16,568 KB
testcase_14 AC 102 ms
16,936 KB
testcase_15 AC 97 ms
16,788 KB
testcase_16 AC 93 ms
16,476 KB
testcase_17 AC 90 ms
16,572 KB
testcase_18 AC 92 ms
16,512 KB
testcase_19 AC 90 ms
16,572 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