結果
問題 |
No.2683 Two Sheets
|
ユーザー |
|
提出日時 | 2024-03-20 22:50:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 825 bytes |
コンパイル時間 | 873 ms |
コンパイル使用メモリ | 76,396 KB |
最終ジャッジ日時 | 2025-02-20 09:50:28 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#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"; }