結果

問題 No.2683 Two Sheets
ユーザー kokoseikokosei
提出日時 2024-03-21 10:00:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 3,665 ms
コンパイル使用メモリ 247,884 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-21 10:00:09
合計ジャッジ時間 4,981 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 4 ms
6,676 KB
testcase_03 AC 43 ms
6,676 KB
testcase_04 AC 10 ms
6,676 KB
testcase_05 AC 40 ms
6,676 KB
testcase_06 AC 34 ms
6,676 KB
testcase_07 AC 28 ms
6,676 KB
testcase_08 AC 50 ms
6,676 KB
testcase_09 AC 30 ms
6,676 KB
testcase_10 AC 49 ms
6,676 KB
testcase_11 AC 43 ms
6,676 KB
testcase_12 AC 36 ms
6,676 KB
testcase_13 AC 59 ms
6,676 KB
testcase_14 AC 55 ms
6,676 KB
testcase_15 AC 40 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int H, W, A, B;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> H >> W >> A >> B;
    mint h = 0, w = 0;
    for(int i = 1;i <= H;i++){
        mint p = min(H - A + 1, i) - max(1, i - A + 1) + 1;
        mint q = H - A + 1;
        mint v = p / q;
        h += v * v;
    }
    for(int i = 1;i <= W;i++){
        mint p = min(W - B + 1, i) - max(1, i - B + 1) + 1;
        mint q = W - B + 1;
        mint v = p / q;
        w += v * v;
    }
    mint ans = mint::raw(2) * A * B - h * w;
    cout << ans.val() << endl;
    return 0;
}
0