結果
問題 |
No.1044 正直者大学
|
ユーザー |
![]() |
提出日時 | 2020-07-11 20:49:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 167 ms / 2,000 ms |
コード長 | 2,346 bytes |
コンパイル時間 | 798 ms |
コンパイル使用メモリ | 83,512 KB |
実行使用メモリ | 78,464 KB |
最終ジャッジ日時 | 2024-10-13 12:32:31 |
合計ジャッジ時間 | 6,352 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#include <iostream> #include<vector> #include<algorithm> #include<string> #include<map> #include<set> #include<stack> #include<queue> #include<math.h> using namespace std; typedef long long ll; #define int long long #define double long double typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; typedef vector<string> VS; typedef priority_queue<int> PQ; 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 fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i<n;i++) #define eREP(i,n) for(int i=0;i<=n;i++) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define eFOR(i,a,b) for(int i=(a);i<=(b);++i) #define SORT(c) sort((c).begin(),(c).end()) #define rSORT(c) sort((c).rbegin(),(c).rend()) #define LB(x,a) lower_bound((x).begin(),(x).end(),(a)) #define UB(x,a) upper_bound((x).begin(),(x).end(),(a)) #define INF 1000000000 #define LLINF 9223372036854775807 #define mod 1000000007 #define eps 1e-12 //priority_queue<int,vector<int>, greater<int> > q2; ll comb(ll N_, ll C_) { const int NUM_ = 3000001; static ll fact[3000002], factr[3000002], inv[3000002]; if (fact[0] == 0) { inv[1] = fact[0] = factr[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod; for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod; } if (C_<0 || C_>N_) return 0; return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod; } ll modpow(ll a, ll n = mod - 2) { ll r = 1; while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a%mod, n >>= 1; return r; } const int SIZE = 200010; ll inv[SIZE], fac[SIZE], finv[SIZE]; void make() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < SIZE; i++) { inv[i] = mod - inv[mod%i] * (mod / i) % mod; fac[i] = fac[i - 1] * (ll)i%mod; finv[i] = finv[i - 1] * inv[i] % mod; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); make(); int N, M, K; cin >> N >> M >> K; int ans = 0; eREP(i, min(M, N)) { int cnt = 2 * i; cnt = N + M - cnt; if (cnt >= K) { ans += comb(N, i)*comb(M - 1, i - 1) % mod; ans %= mod; } } ans = ans * fac[N - 1] % mod; ans = ans * fac[M] % mod; cout << ans << endl; return 0; }