結果

問題 No.2683 Two Sheets
ユーザー 👑 rin204
提出日時 2024-02-29 22:24:23
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 2,998 ms
コンパイル使用メモリ 248,632 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-29 13:03:04
合計ジャッジ時間 3,362 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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