結果

問題 No.1191 数え上げを愛したい(数列編)
ユーザー tikitaka1201tikitaka1201
提出日時 2020-09-16 22:40:52
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 598 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 96,996 KB
最終ジャッジ日時 2023-09-04 04:07:20
合計ジャッジ時間 7,078 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
93,328 KB
testcase_01 AC 340 ms
94,568 KB
testcase_02 AC 159 ms
96,428 KB
testcase_03 AC 153 ms
94,112 KB
testcase_04 AC 323 ms
96,944 KB
testcase_05 AC 98 ms
85,536 KB
testcase_06 AC 575 ms
96,804 KB
testcase_07 AC 172 ms
96,632 KB
testcase_08 AC 172 ms
96,580 KB
testcase_09 AC 175 ms
96,616 KB
testcase_10 AC 98 ms
95,828 KB
testcase_11 AC 98 ms
95,884 KB
testcase_12 AC 309 ms
96,888 KB
testcase_13 AC 404 ms
96,820 KB
testcase_14 AC 473 ms
96,996 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 81 ms
79,592 KB
testcase_18 AC 80 ms
79,648 KB
testcase_19 RE -
testcase_20 AC 80 ms
80,192 KB
testcase_21 RE -
testcase_22 AC 95 ms
93,352 KB
testcase_23 AC 73 ms
71,280 KB
testcase_24 AC 72 ms
71,072 KB
testcase_25 AC 72 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,a,b=map(int,input().split())

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