結果

問題 No.2683 Two Sheets
ユーザー Maffy-0Maffy-0
提出日時 2024-03-21 16:43:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 204,252 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-21 16:43:45
合計ジャッジ時間 3,739 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 5 ms
6,676 KB
testcase_03 AC 45 ms
6,676 KB
testcase_04 AC 11 ms
6,676 KB
testcase_05 AC 42 ms
6,676 KB
testcase_06 AC 36 ms
6,676 KB
testcase_07 AC 30 ms
6,676 KB
testcase_08 AC 53 ms
6,676 KB
testcase_09 AC 32 ms
6,676 KB
testcase_10 AC 52 ms
6,676 KB
testcase_11 AC 47 ms
6,676 KB
testcase_12 AC 39 ms
6,676 KB
testcase_13 AC 62 ms
6,676 KB
testcase_14 AC 59 ms
6,676 KB
testcase_15 AC 41 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using mint = atcoder::modint998244353;

void fast_io() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
}

mint f(int H, int A) {
    mint res;
    for (int i = 0; i < H; i++) {
        int L = max(0, i - A + 1);
        int R = min(i, H - A);
        mint add = mint(R - L + 1) / (H - A + 1);
        add *= add;
        res += add;
    }
    return res;
}

signed main(void) {
    fast_io();
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    mint ans = mint(2) * A * B;
    ans -= f(H, A) * f(W, B);
    cout << ans.val() << endl;
    return 0;
}
0