結果

問題 No.2683 Two Sheets
ユーザー 👑 rin204rin204
提出日時 2024-02-29 22:24:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 2,974 ms
コンパイル使用メモリ 248,032 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-02-29 22:24:27
合計ジャッジ時間 3,996 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 3 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 3 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include "atcoder/modint.hpp"
using mint = atcoder::modint998244353;

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    mint row = 0;
    for (int i = 1; i <= a; i++) {
        int le = 2 * a - i;
        if (le > h) continue;
        row += mint(i) * (h - le + 1) * (i == a ? 1 : 2);
    }
    mint col = 0;
    for (int i = 1; i <= b; i++) {
        int le = 2 * b - i;
        if (le > w) continue;
        col += mint(i) * (w - le + 1) * (i == b ? 1 : 2);
    }

    mint ans = row * col;
    ans /= mint(h - a + 1).pow(2) * mint(w - b + 1).pow(2);
    ans = mint(2) * a * b - ans;
    cout << ans.val() << endl;
}
0