結果

問題 No.1044 正直者大学
ユーザー 沙耶花沙耶花
提出日時 2020-05-01 22:18:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,473 bytes
コンパイル時間 3,751 ms
コンパイル使用メモリ 206,572 KB
実行使用メモリ 11,720 KB
最終ジャッジ日時 2023-08-26 14:45:04
合計ジャッジ時間 5,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
11,408 KB
testcase_01 AC 22 ms
11,720 KB
testcase_02 AC 23 ms
11,484 KB
testcase_03 AC 22 ms
11,452 KB
testcase_04 AC 23 ms
11,500 KB
testcase_05 AC 24 ms
11,424 KB
testcase_06 AC 46 ms
11,400 KB
testcase_07 AC 24 ms
11,412 KB
testcase_08 AC 23 ms
11,524 KB
testcase_09 AC 24 ms
11,536 KB
testcase_10 AC 23 ms
11,460 KB
testcase_11 AC 21 ms
11,536 KB
testcase_12 AC 24 ms
11,472 KB
testcase_13 AC 34 ms
11,536 KB
testcase_14 AC 24 ms
11,540 KB
testcase_15 AC 24 ms
11,544 KB
testcase_16 AC 33 ms
11,476 KB
testcase_17 AC 26 ms
11,420 KB
testcase_18 AC 30 ms
11,584 KB
testcase_19 AC 23 ms
11,412 KB
testcase_20 AC 22 ms
11,404 KB
testcase_21 AC 24 ms
11,472 KB
testcase_22 AC 22 ms
11,524 KB
testcase_23 AC 22 ms
11,524 KB
testcase_24 AC 23 ms
11,584 KB
testcase_25 AC 22 ms
11,408 KB
testcase_26 AC 22 ms
11,408 KB
testcase_27 AC 22 ms
11,424 KB
testcase_28 AC 23 ms
11,472 KB
testcase_29 AC 23 ms
11,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};

int main(){
	
	int N,M,K;
	cin>>N>>M>>K;
	
	combi C(1000000);
	
	int ans = 0;
	
	for(int i=1;true;i++){
		if(N+M-i*2<K)break;
		if(N<i||M<i)break;
		int t = mod(C.junretsu(N-i,i-1)*C.junretsu(M-i,i-1));
		t = mod(t * C.combination(N,i));
		t = mod(t * C.kaijou[i]);
		t = mod(t * C.kaijou[N-i]);
		
		t = mod(t * C.combination(M,i));
		t = mod(t * C.kaijou[i]);
		t = mod(t * gyakugen(i));
		t = mod(t * C.kaijou[M-i]);
		
		ans = mod(ans + t);
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}
0