結果

問題 No.2683 Two Sheets
ユーザー arad
提出日時 2023-12-12 16:30:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,308 bytes
コンパイル時間 4,736 ms
コンパイル使用メモリ 252,552 KB
最終ジャッジ日時 2025-02-18 10:31:31
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using mint = modint998244353;

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    mint ans = 0;
    for(int x0 = 0;x0 <= h-a;x0++){
        for(int y0 = 0;y0 <= w-b;y0++){
            for(int x1 = 0;x1 <= h-a;x1++){
                for(int y1 = 0;y1 <= w-b;y1++){
                    vector<vector<int>> board(h,vector<int>(w));
                    for(int i = x0;i < x0+a;i++){
                        for(int j = y0;j < y0+b;j++){
                            board[i][j] = 1;
                        }
                    }
                    for(int i = x1;i < x1+a;i++){
                        for(int j = y1;j < y1+b;j++){
                            board[i][j] = 1;
                        }
                    }
                    int count = 0;
                    for(int i = 0;i < h;i++){
                        for(int j = 0;j < w;j++){
                            count += board[i][j];
                        }
                    }
                    mint ad = count;
                    ad /= mint(h-a+1)*mint(w-b+1);
                    ad /= mint(h-a+1)*mint(w-b+1);
                    ans += ad;
                }
            }
        }
    }
    cout << ans.val() << endl;
}
0