結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー tikitaka1201tikitaka1201
提出日時 2020-09-16 22:42:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 581 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 97,008 KB
最終ジャッジ日時 2023-09-04 04:07:27
合計ジャッジ時間 6,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
93,216 KB
testcase_01 AC 349 ms
94,388 KB
testcase_02 AC 167 ms
96,284 KB
testcase_03 AC 159 ms
94,048 KB
testcase_04 AC 334 ms
96,768 KB
testcase_05 AC 107 ms
85,744 KB
testcase_06 AC 581 ms
97,008 KB
testcase_07 AC 175 ms
96,340 KB
testcase_08 AC 177 ms
96,544 KB
testcase_09 AC 176 ms
96,456 KB
testcase_10 AC 108 ms
95,764 KB
testcase_11 AC 98 ms
95,784 KB
testcase_12 AC 312 ms
96,532 KB
testcase_13 AC 411 ms
96,552 KB
testcase_14 AC 484 ms
96,880 KB
testcase_15 AC 81 ms
71,504 KB
testcase_16 AC 76 ms
71,616 KB
testcase_17 AC 76 ms
71,308 KB
testcase_18 AC 80 ms
71,196 KB
testcase_19 AC 78 ms
71,208 KB
testcase_20 AC 77 ms
71,208 KB
testcase_21 AC 79 ms
71,192 KB
testcase_22 AC 102 ms
93,284 KB
testcase_23 AC 71 ms
71,444 KB
testcase_24 AC 75 ms
71,324 KB
testcase_25 AC 74 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,a,b=map(int,input().split())
if a*(n-1)>b: 
    print(0)
    exit()

mod=998244353
framod=[1]
def framod_calc(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
        framod.append(a)
framod_calc(m, mod)

def permmod(n, k, mod):
    if n<k: return 0
    a=framod[n]
    c=framod[n-k]
    return (a * pow(c, mod-2, mod)) % mod

def combmod(n, k, mod):
    if n<k: return 0
    a=framod[n]
    b=framod[k]
    c=framod[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod

tmp=0
for res in range(b-(n-1)*a+1):
    tmp+=combmod(n+res-2,res,mod)*(m-res-a*(n-1))
    tmp%=mod

print(tmp*permmod(n,n,mod)%mod)
0