結果
| 問題 |
No.2527 H and W
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-02-20 00:43:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 1,324 bytes |
| コンパイル時間 | 1,117 ms |
| コンパイル使用メモリ | 110,048 KB |
| 最終ジャッジ日時 | 2025-02-10 19:09:05 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
using namespace std;
const long long modc=998244353, MAX=1000000;
vector<long long> f, finv;
long long inv(long long x){
long long ans = 1, e = modc-2;
x %= modc;
while (e > 0){
if ((e & 1LL)) ans = (ans * x) % modc;
e = e >> 1LL;
x = (x*x) % modc;
}
return ans;
}
void init(){
f.resize(MAX+1); finv.resize(MAX+1);
f[0] = 1;
for (int i=1; i<=MAX; i++) f[i] = (f[i-1]*i) % modc;
finv[MAX] = inv(f[MAX]);
for (int i=MAX-1; i>=0; i--) finv[i] = (finv[i+1] * (i+1)) % modc;
}
long long C(long long n, long long k){
if (n < k || k < 0) return 0;
return (((f[n] * finv[k]) % modc) * finv[n-k]) % modc;
}
set<long long> factor;
void all_factor(long long n){
factor.clear();
for (long long i = 1; i*i <= n; i++){
if (n % i == 0){
factor.insert(i);
factor.insert(n / i);
}
}
}
int main(){
init();
long long H, W, K, ans=0;
cin >> H >> W >> K;
all_factor(K);
for (auto x : factor){
ans += (C(H, x) * C(W, K/x)) % modc;
ans %= modc;
}
cout << ans << endl;
return 0;
}
srjywrdnprkt