結果

問題 No.2683 Two Sheets
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-03-29 12:17:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 2,276 ms
コンパイル使用メモリ 204,252 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-29 12:17:21
合計ジャッジ時間 3,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;
using ll = long long;

using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    //2*L c1*i c2*i - L^2 c1*i*i c2*i*i

    ll H, W, A, B, hx, hy, wx, wy;
    cin >> H >> W >> A >> B;
    if (A*2 <= H) hx = A-1, hy = H-A*2+2;
    else hx = H-A, hy = H-(H-A)*2;
    if (B*2 <= W) wx = B-1, wy = W-B*2+2;
    else wx = W-B, wy = W-(W-B)*2;

    mint L = mint((H-A+1) * (W-B+1)).inv(), ans=0;
    ans += L * 2 * (hx+hy) * (hx+1) * (wx+wy) * (wx+1);
    ans -= L * L * (hx*(hx+1)*(2*hx+1)/3 + hy*(hx+1)*(hx+1)) * (wx*(wx+1)*(2*wx+1)/3 + wy*(wx+1)*(wx+1));
    
    cout << ans.val() << endl;

    return 0;
}
0