結果

問題 No.1044 正直者大学
ユーザー Y17
提出日時 2020-05-01 22:45:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 169,524 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-12-25 13:39:38
合計ジャッジ時間 2,720 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0