結果
問題 |
No.2527 H and W
|
ユーザー |
![]() |
提出日時 | 2023-11-04 22:15:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 291 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 2,882 ms |
コンパイル使用メモリ | 246,144 KB |
実行使用メモリ | 19,148 KB |
最終ジャッジ日時 | 2024-09-25 22:20:29 |
合計ジャッジ時間 | 11,262 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #include<atcoder/modint> using mint = atcoder::modint998244353; const int mx = 2e6; mint fac[mx+1],ifac[mx+1]; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); fac[0] = 1; for(int i = 1;i<=mx;i++) fac[i] = fac[i-1] * i; for(int i = 0;i<=mx;i++) ifac[i] = fac[i].inv(); ll h,w; cin>>h>>w; ll k; cin>>k; ll want = h * w - k; mint ans = 0; for(int i = 0;i<=h;i++){ mint tmp = fac[h] * ifac[i] * ifac[h-i]; ll now = w * i; if(now>want) continue; ll res = want - now; ll one = h - i; if(res%one!=0) continue; ll can = res / one; if(can>w) continue; tmp *= fac[w] * ifac[can] * ifac[w-can]; ans += tmp; } cout<<ans.val()<<endl; }