結果
| 問題 |
No.2683 Two Sheets
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-03-29 12:15:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 765 bytes |
| コンパイル時間 | 2,209 ms |
| コンパイル使用メモリ | 195,656 KB |
| 最終ジャッジ日時 | 2025-02-20 14:30:24 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
//2*L c1*i c2*i - L^2 c1*i*i c2*i*i
ll H, W, A, B, hx, hy, wx, wy;
cin >> H >> W >> A >> B;
if (A*2 <= H) hx = A-1, hy = H-A*2+2;
else hx = H-A, hy = H-(H-A)*2;
if (B*2 <= W) wx = B-1, wy = W-B*2+2;
else wx = W-B, wy = W-(W-B)*2;
mint L = mint((H-A+1) * (W-B+1)).inv(), ans=0;
ans += L * 2 * (hx*(hx+1) + hy*(hx+1)) * (wx*(wx+1) + wy*(wx+1));
ans -= L * L * (hx*(hx+1)*(2*hx+1)/3 + hy*(hx+1)*(hx+1)) * (wx*(wx+1)*(2*wx+1)/3 + wy*(wx+1)*(wx+1));
cout << ans.val() << endl;
return 0;
}
srjywrdnprkt