You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
595 B

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int p = 1e9 + 7;
int n;
int qmi(int a, int b) {
int res = 1;
while (b) {
if (b & 1) res = (LL)res * a % p;
b >>= 1;
a = (LL)a * a % p;
}
return res;
}
int main() {
cin >> n;
int res = 1;
// ① 分子,2n*(2n-1)*(2n-2)*...*(n+1)
for (int i = 2 * n; i > n; i--) res = (LL)res * i % p;
// ② 分母,inv(n+1)*inv(n)*inv(n-1)*...*inv(1) %p
for (int i = n + 1; i; i--) res = (LL)res * qmi(i, p - 2) % p;
// 输出
cout << res << endl;
return 0;
}