結果
問題 |
No.2631 Rectangle Grid Game
|
ユーザー |
|
提出日時 | 2024-02-16 22:42:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 72,804 KB |
最終ジャッジ日時 | 2025-02-19 14:29:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; using ll=long long; #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;} const int MOD=998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll H,W; cin>>H>>W; ll ans=0; ll sh=((H/2-1)*(H/2)%MOD+(H%2?H/2:0))%MOD; ll sw=((W/2-1)*(W/2)%MOD+(W%2?W/2:0))%MOD; ans=(H*W-(H/2+1)*(W/2+1))%MOD*H%MOD*W%MOD; ans+=(W/2+1)*W%MOD*sh%MOD; ans+=(H/2+1)*H%MOD*sw%MOD; ans-=sh*sw%MOD; ans%=MOD; if(ans<0)ans+=MOD; cout<<ans<<"\n"; }