結果

問題 No.2683 Two Sheets
ユーザー aradarad
提出日時 2023-12-13 16:49:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 808 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 204,768 KB
実行使用メモリ 10,004 KB
最終ジャッジ日時 2023-12-13 16:49:19
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 600 ms
6,676 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

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 i1 = 0;i1 < h-a+1;i1++){
        for(int i2 = 0;i2 < h-a+1;i2++){
            int l = max(i1,i2);
            int r = min(i1+a,i2+a);
            if(r-l <= 0) continue;
            ans0 += mint(r-l)/((h-a+1)*(h-a+1));
        }
    }
    mint ans1 = 0;
    for(int j1 = 0;j1 < w-b+1;j1++){
        for(int j2 = 0;j2 < w-b+1;j2++){
            int l = max(j1,j2);
            int r = min(j1+b,j2+b);
            if(r-l <= 0) continue;
            ans1 += mint(r-l)/((w-b+1)*(w-b+1));
        }
    }
    mint ans = ans0*ans1;
    ans = 2*mint(a)*mint(b)-ans;
    cout << ans.val() << endl;
}
0