結果

問題 No.2683 Two Sheets
ユーザー umezoumezo
提出日時 2024-03-21 06:03:01
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 3,125 ms
コンパイル使用メモリ 245,488 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-21 06:03:06
合計ジャッジ時間 4,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 4 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 4 ms
6,676 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

const int MOD=998244353;
ll modpow(ll x,ll n){
  x%=MOD;
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  ll h1=0,h2=0,w1=0,w2=0;
  ll x=(h-a+1)*(w-b+1)%MOD;
  rep(i,h){
    ll th=min(a,min((ll)i+1,h-i));
    h1=(h1+th)%MOD;
    th=th*th%MOD;
    h2=(h2+th)%MOD;
  }
  rep(j,w){
    ll tw=min(b,min((ll)j+1,w-j));
    w1=(w1+tw)%MOD;
    tw=tw*tw%MOD;
    w2=(w2+tw)%MOD;
  }
  ll ans=2*modpow(x,MOD-2)%MOD*h1%MOD*w1%MOD;
  ans=(ans+MOD-modpow(x*x%MOD,MOD-2)*h2%MOD*w2%MOD)%MOD;
  cout<<ans<<endl;
    
  return 0;
}
0