結果

問題 No.2527 H and W
ユーザー coindarwcoindarw
提出日時 2023-11-03 23:26:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 3,098 bytes
コンパイル時間 4,803 ms
コンパイル使用メモリ 268,788 KB
実行使用メモリ 18,564 KB
最終ジャッジ日時 2023-11-03 23:26:47
合計ジャッジ時間 6,584 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 64 ms
18,564 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 65 ms
18,564 KB
testcase_05 AC 65 ms
18,564 KB
testcase_06 AC 64 ms
18,300 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 63 ms
18,564 KB
testcase_09 AC 67 ms
16,980 KB
testcase_10 AC 71 ms
18,564 KB
testcase_11 AC 66 ms
18,300 KB
testcase_12 AC 66 ms
16,716 KB
testcase_13 AC 66 ms
16,716 KB
testcase_14 AC 65 ms
18,300 KB
testcase_15 AC 67 ms
16,716 KB
testcase_16 AC 66 ms
18,564 KB
testcase_17 AC 62 ms
18,564 KB
testcase_18 AC 63 ms
18,564 KB
testcase_19 AC 40 ms
16,716 KB
testcase_20 AC 43 ms
16,716 KB
testcase_21 AC 47 ms
18,564 KB
testcase_22 AC 48 ms
18,300 KB
testcase_23 AC 47 ms
18,564 KB
testcase_24 AC 45 ms
16,716 KB
testcase_25 AC 54 ms
17,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>

#include <atcoder/all>
#else
#include <mylibs/all.h>
#endif

using ll = long long;
using lll = __int128_t;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define length(v) ((int)(v).size())
constexpr int inf = 2'000'000'000;
constexpr ll linf = 4'000'000'000'000'000'000, M7 = 1'000'000'007, M9 = 998'244'353;
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
using namespace std;
using namespace atcoder;

inline ostream& operator<<(ostream& os, lll val) noexcept {
    string s;
    bool neg = val < 0;
    if (val < 0) {
        val *= -1;
    }
    if (val == 0) {
        s += '0';
    } else {
        while (val > 0) {
            s += '0' + val % 10;
            val /= 10;
        }
    }
    reverse(all(s));
    if (neg) s = "-" + s;
    return os << s;
}
inline istream& operator>>(istream& is, lll& val) noexcept {
    string s;
    is >> s;
    bool neg = false;
    if (s[0] == '-') {
        neg = true;
        s = s.substr(1);
    }
    val = 0;
    for (auto c : s) {
        val *= 10;
        val += c - '0';
    }
    if (neg) val *= -1;
    return is;
}

constexpr ll MOD = M9;
using mint = static_modint<MOD>;
struct modInv {
    int n;
    vector<mint> d;
    modInv() : n(2), d({0, 1}) {}
    mint operator()(int i) {
        while (n <= i) d.emplace_back(-d[MOD % n] * (MOD / n)), ++n;
        return d[i];
    }
    mint operator[](int i) const { return d[i]; }
} invs;
struct Factorial {
    int n;
    vector<mint> d;
    Factorial() : n(2), d({1, 1}) {}
    mint operator()(int i) {
        while (n <= i) d.emplace_back(d.back() * n), ++n;
        return d[i];
    }
    mint operator[](int i) const { return d[i]; }
} factorial;
struct FactorialInv {
    int n;
    vector<mint> d;
    FactorialInv() : n(2), d({1, 1}) {}
    mint operator()(int i) {
        while (n <= i) d.emplace_back(d.back() * invs(n)), ++n;
        return d[i];
    }
    mint operator[](int i) const { return d[i]; }
} factorialInv;
mint P(int n, int r) {
    if (n < r || n < 0 || r < 0) return 0;
    return factorial(n) * factorialInv(n - r);
}
mint C(int n, int r) {
    if (n < r || n < 0 || r < 0) return 0;
    return factorial(n) * factorialInv(r) * factorialInv(n - r);
}
mint H(int n, int r) {
    const int _n = n + r - 1;
    if (_n < r || _n < 0 || r < 0) return 0;
    return factorial(_n) * factorialInv(r) * factorialInv(_n - r);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lll h, w, k;
    cin >> h >> w >> k;
    lll l = h * w - k;
    mint ans = 0;
    rep(x, w) {
        if ((l - x * h) % (w - x) == 0) {
            lll y = (l - x * h) / (w - x);
            ans += C(w, x) * C(h, y);
        }
    }
    cout << ans.val() << endl;
    return 0;
}
0