結果

問題 No.2527 H and W
ユーザー soyamashsoyamash
提出日時 2023-11-04 11:30:45
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,844 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 64,212 KB
実行使用メモリ 26,588 KB
最終ジャッジ日時 2023-11-04 11:31:09
合計ジャッジ時間 23,229 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
26,588 KB
testcase_01 AC 43 ms
26,588 KB
testcase_02 AC 44 ms
26,588 KB
testcase_03 AC 40 ms
26,588 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 AC 42 ms
26,588 KB
testcase_08 AC 42 ms
26,588 KB
testcase_09 AC 44 ms
26,588 KB
testcase_10 AC 44 ms
26,588 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 43 ms
26,588 KB
testcase_17 AC 44 ms
26,588 KB
testcase_18 AC 45 ms
26,588 KB
testcase_19 AC 46 ms
26,588 KB
testcase_20 AC 39 ms
26,588 KB
testcase_21 AC 41 ms
26,588 KB
testcase_22 AC 41 ms
26,588 KB
testcase_23 AC 40 ms
26,588 KB
testcase_24 AC 42 ms
26,588 KB
testcase_25 AC 40 ms
26,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; //cin, coutを使う

long long big_num = 998244353 ;

const long long MAX = 1000005;
const long long MOD = 998244353;

std::vector<long long> fac, finv, inv;

// テーブルを作る前処理
void COMinit() {
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if (n == k) return 1;
    if (n == 1) return k;
    if (k == 1) return n;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int min_x (int a, int b){
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int Cx(int a, int b){
    long long i = 1;
    for (int h = 0; h < b; h++){
        i *= (a - h);
        i /= (b - h);
    }
    if (i > big_num) i %= big_num;
    return (int)i;
};




int main(){
    int H, W, K;
    cin >> H >> W >> K;
    if (H > W){
        int s = W;
        W = H;
        H = s;
    }
    COMinit();


    long long ret = 0;
    for (int i = 1; i <= K; i++ ){
        if (i > H || K % i != 0) continue;
        if (K / i > K) continue;
        long long hi = COM(H, i);
        if (hi > big_num) hi %= big_num;
        long long wk_i = COM(W, (int)(K / i));
        if (wk_i > big_num) wk_i %= big_num;
        ret += hi * wk_i;
        //std::cout << hi << std::endl;
        //std::cout << wk_i << std::endl;
        //std::cout << i << " " << hi * wk_i << " " << ret << std::endl;
        if (ret > big_num) ret %= big_num;
    }

    cout << ret << endl;
};
0