結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー titiatitia
提出日時 2020-08-22 16:22:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 534 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,432 KB
最終ジャッジ日時 2024-04-23 10:32:07
合計ジャッジ時間 11,673 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
34,304 KB
testcase_01 AC 527 ms
34,432 KB
testcase_02 AC 472 ms
34,304 KB
testcase_03 AC 474 ms
34,304 KB
testcase_04 AC 510 ms
34,304 KB
testcase_05 AC 332 ms
34,432 KB
testcase_06 AC 534 ms
34,432 KB
testcase_07 AC 502 ms
34,304 KB
testcase_08 AC 496 ms
34,432 KB
testcase_09 AC 495 ms
34,304 KB
testcase_10 AC 470 ms
34,304 KB
testcase_11 AC 479 ms
34,304 KB
testcase_12 AC 530 ms
34,304 KB
testcase_13 AC 518 ms
34,304 KB
testcase_14 AC 513 ms
34,304 KB
testcase_15 AC 254 ms
34,432 KB
testcase_16 AC 247 ms
34,304 KB
testcase_17 AC 275 ms
34,432 KB
testcase_18 AC 276 ms
34,304 KB
testcase_19 AC 270 ms
34,432 KB
testcase_20 AC 283 ms
34,432 KB
testcase_21 AC 228 ms
34,304 KB
testcase_22 AC 436 ms
34,304 KB
testcase_23 AC 208 ms
34,432 KB
testcase_24 AC 214 ms
34,304 KB
testcase_25 AC 215 ms
34,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import deque

N,M,A,B=map(int,input().split())
mod=998244353

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

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(3*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]*FACT_INV[a-b]%mod
    else:
        return 0

ANS=0
for start in range(1,M+1):
    kosuu=min(M,start+B)-start
    #print(kosuu)
    if kosuu < 0:
        break
    

    ANS+=Combi(kosuu-(N-1)*(A-1),N-1)
    #print(ANS*FACT[N]%mod)

print(ANS*FACT[N]%mod)

    
    
0