結果

問題 No.2381 Gift Exchange Party
ユーザー titiatitia
提出日時 2023-07-15 05:05:22
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 593 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 137,248 KB
最終ジャッジ日時 2023-10-14 19:39:51
合計ジャッジ時間 7,907 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
133,940 KB
testcase_01 AC 130 ms
133,912 KB
testcase_02 AC 130 ms
134,000 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 130 ms
133,956 KB
testcase_07 RE -
testcase_08 AC 127 ms
134,052 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 131 ms
133,836 KB
testcase_12 AC 132 ms
134,348 KB
testcase_13 AC 131 ms
134,052 KB
testcase_14 AC 145 ms
137,248 KB
testcase_15 AC 129 ms
134,144 KB
testcase_16 AC 133 ms
133,844 KB
testcase_17 AC 130 ms
133,912 KB
testcase_18 AC 133 ms
134,264 KB
testcase_19 AC 131 ms
133,900 KB
testcase_20 AC 180 ms
134,360 KB
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 181 ms
134,092 KB
testcase_24 AC 130 ms
134,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mod=998244353

FACT=[1]
for i in range(1,4*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(4*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
x=1
for i in range(0,10**5):
    if i*P>N:
        break
    now=i*P

    if now-P>=0:
        x=x*Combi(now,now-P)%mod

    ANS+=x*FACT_INV[i]%mod*pow(FACT[P-1],i,mod)*Combi(N,i*P)%mod
    ANS%=mod

print((FACT[N]-ANS)%mod)



0