結果

問題 No.2527 H and W
ユーザー ochiaigawaochiaigawa
提出日時 2023-11-03 21:39:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 208,108 KB
実行使用メモリ 10,832 KB
最終ジャッジ日時 2023-11-03 21:39:21
合計ジャッジ時間 3,578 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
10,832 KB
testcase_01 AC 12 ms
10,832 KB
testcase_02 AC 20 ms
10,832 KB
testcase_03 AC 11 ms
10,832 KB
testcase_04 AC 20 ms
10,832 KB
testcase_05 AC 21 ms
10,832 KB
testcase_06 AC 20 ms
10,832 KB
testcase_07 AC 11 ms
10,832 KB
testcase_08 AC 20 ms
10,832 KB
testcase_09 AC 11 ms
10,832 KB
testcase_10 AC 12 ms
10,832 KB
testcase_11 AC 21 ms
10,832 KB
testcase_12 AC 20 ms
10,832 KB
testcase_13 AC 20 ms
10,832 KB
testcase_14 AC 21 ms
10,832 KB
testcase_15 AC 20 ms
10,832 KB
testcase_16 AC 20 ms
10,832 KB
testcase_17 AC 21 ms
10,832 KB
testcase_18 AC 20 ms
10,832 KB
testcase_19 AC 17 ms
10,832 KB
testcase_20 AC 17 ms
10,832 KB
testcase_21 AC 20 ms
10,832 KB
testcase_22 AC 21 ms
10,832 KB
testcase_23 AC 21 ms
10,832 KB
testcase_24 AC 16 ms
10,832 KB
testcase_25 AC 12 ms
10,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using mint = atcoder::modint998244353;
const int MAX = 2000005;
vector<mint> fac(MAX, mint(1));

void COMinit() {
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * mint(i);
    }
}

mint COM(int n, int k){
    if(n < k) return mint(0);
    if(n < 0 || k < 0) return mint(0);
    return fac[n] / fac[k] / fac[n - k];
}
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  COMinit();
  long H, W, K;
  cin >> H >> W >> K;
  mint ans = 0;
  for(int i = 0; i < H; i++) {
    long rem = W * i;
    if((H * W - rem - K) % (H - i) == 0 && 0 <= (H * W - rem - K) / (H - i) && (H * W - rem - K) / (H - i) <= W) {
      ans += COM(H, i) * COM(W, (H * W - rem - K) / (H - i));
    }
  }
  cout << ans.val() << '\n';
  return 0;
}
0