結果
問題 | No.2631 Rectangle Grid Game |
ユーザー | cho435 |
提出日時 | 2024-02-16 23:39:58 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 3,640 ms |
コンパイル使用メモリ | 264,072 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 22:41:53 |
合計ジャッジ時間 | 4,479 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; int main(){ ll h,w; cin>>h>>w; ll ch=(h/2),cw=(w/2); mint ans=0; mint td=h*w-(ch+1)*(cw+1); ans+=(td*ch*cw)*4; ans+=(mint(ch+1)*(cw+1)*ch*cw)*4; ans-=((mint(ch+1)*(ch+1)+ch-1)*(mint(cw+1)*(cw+1)+cw-1)); if(h&1){ ans+=mint(cw)*h*w*2-cw*(cw+3); } if(w&1){ ans+=mint(ch)*w*h*2-ch*(ch+3); } if((h&1)&&(w&1)){ ans+=mint(h)*w-1; } cout<<ans.val()<<endl; }