結果

問題 No.2683 Two Sheets
ユーザー nikoro256nikoro256
提出日時 2024-03-22 17:22:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 898 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 59,600 KB
最終ジャッジ日時 2024-03-22 17:22:13
合計ジャッジ時間 3,071 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 41 ms
59,600 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 40 ms
59,600 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 41 ms
59,600 KB
testcase_13 WA -
testcase_14 AC 36 ms
53,460 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a % b)
        y -= (a // b) * x
        return d, x, y
    return a, 1, 0

#以下modinv
def mod_inv(a, m):
    g, x, y = extgcd(a, m)

    if g != 1:
        raise Exception()

    if x < 0:
        x += m

    return x

H,W,A,B=map(int,input().split())
Hm=0
p=998244353
for i in range(1,A+1):
    if i!=A:
        Hm+=i*(H-(2*A-i)+1)*2
    else:
        Hm+=i*(H-(2*A-i)+1)
    Hm%=p
Wm=0
for i in range(1,B+1):
    if i!=B:
        Wm+=i*(W-(2*B-i)+1)*2
    else:
        Wm+=i*(W-(2*B-i)+1)
    Wm%=p
ans=((H-A+1)*(W-B+1))**2%p*(A*B*2)%p
inv=mod_inv((((H-A+1)*(W-B+1))**2),p)
print((ans-Hm*Wm)%p*inv%p)
0