結果

問題 No.2527 H and W
ユーザー Iroha_3856Iroha_3856
提出日時 2024-07-28 21:43:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 3,226 ms
コンパイル使用メモリ 252,988 KB
実行使用メモリ 11,124 KB
最終ジャッジ日時 2024-07-28 21:43:36
合計ジャッジ時間 4,932 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint998244353;

struct combination {
	vector<mint> fac, infac;
	combination(int n) {
		fac.resize(n+1);
		infac.resize(n+1);
		fac[0] = 1;
		for (int i = 1; i <= n; i++) fac[i] = fac[i-1] * i;
		infac[n] = fac[n].inv(); 
		for (int i = n; i >= 1; i--) infac[i-1] = infac[i] * i;
	}
	mint operator()(int n, int c) {
		if (c > n) return 0;
		return fac[n]*infac[c]*infac[n-c];
	}
} comb(1000009);

int main() {
	int h, w; cin >> h >> w;
	long long k; cin >> k;
	vector<long long> D; 
	for (long long d = 1; d*d <= k; d++) {
		if (k%d) continue;
		D.push_back(d);
		if (k != d * d) D.push_back(k/d);
	}
	mint ans = 0;
	for (auto t : D) {
		//tate : d
		long long y = k/t;
        if (t > h || y > w) continue;
		ans += comb(h, t) * comb(w, y);
	}
	cout << ans.val() << endl;
}
0