結果

問題 No.2683 Two Sheets
ユーザー 👑 tute7627tute7627
提出日時 2024-03-03 18:24:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 2,829 ms
コンパイル使用メモリ 205,032 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-03 18:24:44
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif
int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  assert(1 <= H && H <= 2e5);
  assert(1 <= W && W <= 2e5);

  using modint = atcoder::modint998244353;
  modint xs = 0, ys = 0;
  for(int x = 0; x < H; x++){
    modint prob = modint(max<int>(x - A + 1, 0) + max<int>(0, H - A - x)) / (H - A + 1);
    xs += (1 - prob) * (1 - prob);
  }
  for(int y = 0; y < W; y++){
    modint prob = modint(max<int>(y - B + 1, 0) + max<int>(0, W - B - y)) / (W - B + 1);
    ys += (1 - prob) * (1 - prob);
  }

  cout << (modint(2) * A * B - xs * ys).val() << endl;
}
0