結果

問題 No.1044 正直者大学
ユーザー Y17Y17
提出日時 2020-05-01 22:45:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 168,232 KB
実行使用メモリ 6,256 KB
最終ジャッジ日時 2023-08-26 15:28:50
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 6 ms
6,256 KB
testcase_06 AC 8 ms
6,136 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 4 ms
4,584 KB
testcase_13 AC 5 ms
5,036 KB
testcase_14 AC 5 ms
4,892 KB
testcase_15 AC 6 ms
5,880 KB
testcase_16 AC 7 ms
5,144 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 6 ms
5,508 KB
testcase_24 AC 3 ms
4,508 KB
testcase_25 AC 4 ms
4,608 KB
testcase_26 AC 5 ms
5,152 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<int64_t mod> struct Combination{
    vector<int64_t> f, rf;
 
    Combination(int max_n): f(max_n+1), rf(max_n+1){
        f[0] = 1;
        for(int i = 1;i <= max_n;i++) f[i] = f[i-1] * i % mod;
		int64_t a = f[max_n], inv = 1;
		for(int64_t b = mod-2;b > 0;b>>=1){
			if(b & 1) inv = inv*a % mod;
			a = a * a % mod;
		}
		for(int i = max_n;i >= 0;i--) inv = (rf[i] = inv) * i % mod;
    }
 
    int64_t operator()(int n, int r){
        return (r < 0 || n < r) ? 0 : f[n] * rf[r] % mod * rf[n-r] % mod;
    }
};

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

signed main(){
	int n, m, k;
	cin >> n >> m >> k;

	Combination<MOD> combi(n+m);

	int nkai, mkai;
	nkai = mkai = 1;
	for(int i = 1;i <= n;i++) nkai = (nkai * i) % MOD; 
	for(int i = 1;i <= m-1;i++) mkai = (mkai * i) % MOD; 

	int ans = 0;
	for(int i = 1;i <= m;i++){
		if(n-1 < i-1) break;
		if(n+m-i*2 < k) continue;
		int c1 = combi(n-1, i-1) * nkai % MOD;
		int c2 = combi(m, i) * mkai % MOD;
		ans += (c1 * c2) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}
0