結果

問題 No.2683 Two Sheets
ユーザー aradarad
提出日時 2023-12-12 16:28:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 204,900 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-13 15:32:08
合計ジャッジ時間 3,474 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 44 ms
6,676 KB
testcase_04 AC 11 ms
6,676 KB
testcase_05 AC 41 ms
6,676 KB
testcase_06 AC 34 ms
6,676 KB
testcase_07 AC 29 ms
6,676 KB
testcase_08 AC 52 ms
6,676 KB
testcase_09 AC 33 ms
6,676 KB
testcase_10 AC 51 ms
6,676 KB
testcase_11 AC 45 ms
6,676 KB
testcase_12 AC 38 ms
6,676 KB
testcase_13 AC 60 ms
6,676 KB
testcase_14 AC 58 ms
6,676 KB
testcase_15 AC 41 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using mint = modint998244353;

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    mint ans0 = 0;
    for(int i = 0;i < h;i++){
        int l = max(0,i-a+1);
        int r = min(h-a,i);
        mint ad = mint(r-l+1)/(h-a+1);
        ad *= ad;
        ans0 += ad;
    }
    mint ans1 = 0;
    for(int i = 0;i < w;i++){
        int l = max(0,i-b+1);
        int r = min(w-b,i);
        mint ad = mint(r-l+1)/(w-b+1);
        ad *= ad;
        ans1 += ad;
    }
    mint ans = ans0*ans1;
    ans = 2*mint(a)*mint(b)-ans;
    cout << ans.val() << endl;
}
0