結果

問題 No.2683 Two Sheets
ユーザー 沙耶花沙耶花
提出日時 2024-03-20 21:25:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 4,855 ms
コンパイル使用メモリ 262,084 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 21:25:08
合計ジャッジ時間 5,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	long long H,W,A,B;
	cin>>H>>W>>A>>B;
	
	mint t = A;
	t *= B;
	t *= H-A+1;
	t *= W-B+1;
	t *= H-A+1;
	t *= W-B+1;
	t *= 2;
	mint h = 0,w = 0;
	rep(_,2){
		for(int i=A-1;true;i--){
			int x = 0,y = A-1,z = i,w = i+A-1;
			int d = max(y,w) - min(x,z) + 1;
			if(d >= A*2)break;
			mint tt = A*2 - d;
			tt *= max(0LL,H - d + 1);
			h += tt;
		}
		swap(h,w);
		swap(H,W);
		swap(A,B);
	}
	//cout<<h.val()<<' '<<w.val()<<endl;
	t -= h * w;
	t /= H-A+1;
	t /= W-B+1;
	t /= H-A+1;
	t /= W-B+1;
	cout<<t.val()<<endl;
	
	return 0;
}
0