結果

問題 No.727 仲介人moko
ユーザー gazellegazelle
提出日時 2018-08-24 21:49:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 433 ms / 1,000 ms
コード長 1,740 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 201,700 KB
実行使用メモリ 18,752 KB
最終ジャッジ日時 2023-09-05 11:25:40
合計ジャッジ時間 7,069 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
18,712 KB
testcase_01 AC 18 ms
18,524 KB
testcase_02 AC 18 ms
18,632 KB
testcase_03 AC 30 ms
18,644 KB
testcase_04 AC 17 ms
18,624 KB
testcase_05 AC 18 ms
18,640 KB
testcase_06 AC 17 ms
18,752 KB
testcase_07 AC 17 ms
18,492 KB
testcase_08 AC 17 ms
18,620 KB
testcase_09 AC 17 ms
18,576 KB
testcase_10 AC 18 ms
18,516 KB
testcase_11 AC 18 ms
18,684 KB
testcase_12 AC 17 ms
18,548 KB
testcase_13 AC 17 ms
18,516 KB
testcase_14 AC 200 ms
18,564 KB
testcase_15 AC 325 ms
18,468 KB
testcase_16 AC 169 ms
18,636 KB
testcase_17 AC 206 ms
18,424 KB
testcase_18 AC 145 ms
18,472 KB
testcase_19 AC 364 ms
18,464 KB
testcase_20 AC 207 ms
18,748 KB
testcase_21 AC 117 ms
18,432 KB
testcase_22 AC 101 ms
18,620 KB
testcase_23 AC 407 ms
18,580 KB
testcase_24 AC 433 ms
18,688 KB
testcase_25 AC 283 ms
18,480 KB
testcase_26 AC 342 ms
18,580 KB
testcase_27 AC 282 ms
18,684 KB
testcase_28 AC 26 ms
18,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

#define MAX_N 2000020
long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
long long mod_inverse(long long a, long long m) {
	long long x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<long long> fact(MAX_N+1, INF);
long long mod_fact(long long n, long long& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	long long res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
	if(n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	ll ans=1;
	cin>>n;
	for(ll i=2*n; i>0; i-=2) {
		ans*=mod_comb(i,2);
		ans%=MOD;
	}
	for(ll i=n; i>0; i--) {
		ans*=i;
		ans%=MOD;
	}
	cout<<ans<<endl;
}
0