結果
| 問題 | No.2631 Rectangle Grid Game | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-02-16 23:39:58 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 547 bytes | 
| コンパイル時間 | 4,022 ms | 
| コンパイル使用メモリ | 252,912 KB | 
| 最終ジャッジ日時 | 2025-02-19 15:03:40 | 
| ジャッジサーバーID (参考情報) | judge5 / 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;
}
            
            
            
        