結果
問題 | No.2527 H and W |
ユーザー |
![]() |
提出日時 | 2024-04-02 00:52:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 2,029 ms |
コンパイル使用メモリ | 195,920 KB |
最終ジャッジ日時 | 2025-02-20 19:28:17 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } mint fact[1 << 20], fact_inv[1 << 20]; void calc_fact() { fact[0] = 1; for (int i = 1; i < (1 << 20); i++) { fact[i] = fact[i - 1] * i; } fact_inv[(1 << 20) - 1] = fact[(1 << 20) - 1].inv(); for (int i = (1 << 20) - 2; i >= 0; i--) { fact_inv[i] = fact_inv[i + 1] * (i + 1); } } mint binom(int n, int k) { if (n < k || n < 0 || k < 0) return 0; return fact[n] * fact_inv[k] * fact_inv[n - k]; } int main() { fast_io(); calc_fact(); int h, w; long long k; cin >> h >> w >> k; mint ans = 0; for (int i = 0; i < h; i++) { if (k % (h - i)) { continue; } int j = w - k / (h - i); ans += binom(h, i) * binom(w, j); } cout << ans.val() << endl; }