結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー 37zigen37zigen
提出日時 2020-08-23 05:24:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 494 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 128,500 KB
最終ジャッジ日時 2024-04-23 15:01:04
合計ジャッジ時間 43,122 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1,515 ms
128,496 KB
testcase_16 AC 1,502 ms
128,496 KB
testcase_17 AC 1,469 ms
128,368 KB
testcase_18 AC 1,489 ms
128,492 KB
testcase_19 AC 1,504 ms
128,364 KB
testcase_20 AC 1,716 ms
128,496 KB
testcase_21 AC 1,456 ms
128,368 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1,500 ms
128,492 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=998244353
fac=[1,1]
inv=[1,1]
ifac=[1,1]
for i in range(2,10**6):
    fac.append(i*fac[-1]%MOD)
    inv.append(MOD-MOD//i*inv[MOD%i]%MOD)
    ifac.append(ifac[-1]*inv[i]%MOD)

def comb(n,k):
    if 0<=k<=n:
        return 0
    return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD

N,M,A,B=map(int,input().split())
r=B-A*(N-1)
if r<0:
    exit(print(0))
ans=0
for R in range(r+1):
    ma=A*(N-1)+R+1
    if ma>M:
        continue
    ans+=comb(R+N-2,N-2)*(M-ma+1)%MOD
    ans%=MOD
print(ans*fac[N]%MOD)
0