結果

問題 No.2683 Two Sheets
ユーザー otoshigootoshigo
提出日時 2024-03-20 22:50:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 78,256 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-20 22:50:18
合計ジャッジ時間 2,667 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 7 ms
6,548 KB
testcase_03 AC 89 ms
6,548 KB
testcase_04 AC 21 ms
6,548 KB
testcase_05 AC 83 ms
6,548 KB
testcase_06 AC 71 ms
6,548 KB
testcase_07 AC 58 ms
6,548 KB
testcase_08 AC 105 ms
6,548 KB
testcase_09 AC 62 ms
6,548 KB
testcase_10 AC 103 ms
6,548 KB
testcase_11 AC 91 ms
6,548 KB
testcase_12 AC 76 ms
6,548 KB
testcase_13 AC 123 ms
6,548 KB
testcase_14 AC 118 ms
6,548 KB
testcase_15 AC 81 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<atcoder/modint>
using namespace std;
using ll=long long;
using mint=atcoder::modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

mint p(int H,int A,int i){
    int l=max(i-A+1,1),r=min(i,H-A+1);
    return(mint)max(0,r-l+1)/(H-A+1);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    mint ans=0,p1=0,p2=0;
    for(int i=1;i<=H;i++){
        p1+=p(H,A,i)*p(H,A,i);
    }
    for(int j=1;j<=W;j++){
        p2+=p(W,B,j)*p(W,B,j);
    }
    ans=2*A*B-p1*p2;
    cout<<ans.val()<<"\n";
}
0