結果

問題 No.1044 正直者大学
ユーザー kk
提出日時 2021-02-03 03:06:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 199,764 KB
実行使用メモリ 5,100 KB
最終ジャッジ日時 2023-09-12 11:44:08
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,948 KB
testcase_01 AC 19 ms
4,940 KB
testcase_02 AC 19 ms
4,940 KB
testcase_03 AC 19 ms
4,932 KB
testcase_04 AC 20 ms
5,088 KB
testcase_05 AC 20 ms
4,960 KB
testcase_06 AC 37 ms
4,980 KB
testcase_07 AC 19 ms
4,960 KB
testcase_08 AC 20 ms
4,984 KB
testcase_09 AC 19 ms
4,908 KB
testcase_10 AC 19 ms
4,952 KB
testcase_11 AC 20 ms
4,932 KB
testcase_12 AC 20 ms
4,992 KB
testcase_13 AC 29 ms
4,936 KB
testcase_14 AC 20 ms
4,876 KB
testcase_15 AC 21 ms
5,016 KB
testcase_16 AC 29 ms
4,860 KB
testcase_17 AC 22 ms
4,940 KB
testcase_18 AC 26 ms
4,856 KB
testcase_19 AC 21 ms
4,856 KB
testcase_20 AC 19 ms
4,992 KB
testcase_21 AC 21 ms
4,964 KB
testcase_22 AC 20 ms
4,908 KB
testcase_23 AC 19 ms
4,876 KB
testcase_24 AC 19 ms
4,936 KB
testcase_25 AC 20 ms
5,088 KB
testcase_26 AC 20 ms
4,936 KB
testcase_27 AC 20 ms
4,872 KB
testcase_28 AC 19 ms
5,100 KB
testcase_29 AC 19 ms
4,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const long long MOD = 1e9 + 7;

long long f[100000+1];
long long g[100000+1];

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

long long comb(int n, int k) {
  return f[n] * g[k] % MOD * g[n-k] % MOD;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  f[0] = g[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    f[i] = i * f[i-1] % MOD;
    g[i] = modpow(f[i], MOD-2, MOD);
  }
  
  int n, m, k;
  cin >> n >> m >> k;

  long long ret = 0;
  for (int i = 1; i <= min(n, m); i++) {
    if (n + m - 2 * i >= k) {
      long long pat = comb(n-1, i-1) * comb(m-1, i-1) % MOD;
      pat *= f[n] * f[m] % MOD;
      pat %= MOD;
      pat *= modpow(i, MOD-2, MOD);
      pat %= MOD;
      ret += pat;
      ret %= MOD;
    }
  }
  cout << ret << endl;
  
  return 0;
}
0