結果

問題 No.2683 Two Sheets
ユーザー SPD_9X2
提出日時 2023-12-14 20:48:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 67,712 KB
最終ジャッジ日時 2024-09-27 05:46:35
合計ジャッジ時間 1,525 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

def solve(H,A):

    ret = 0
    for i in range(H-A+1):

        Lmin = max(1,A-i)
        Rmin = max(1,(i+A)-(H-A) )

        ret += (Lmin+A)*(A-Lmin+1)//2 + (Rmin+A)*(A-Rmin+1)//2 - A
        ret %= mod
    
    ret *= pow( (H-A+1)**2 , mod-2 , mod )
    return ret % mod


H,W,A,B = map(int,input().split())

assert 1 <= A <= H <= 2*(10**5)
assert 1 <= B <= W <= 2*(10**5)

ans = (2*A*B - solve(H,A) * solve(W,B)) % mod
print (ans)
0