-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path2064.cpp
More file actions
36 lines (34 loc) · 725 Bytes
/
2064.cpp
File metadata and controls
36 lines (34 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll powmod(ll a, ll b) {
ll res = 1;
for (; b; b >>= 1, (a *= a) %= MOD) {
if (b & 1) {
(res *= a) %= MOD;
}
}
return res;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
if (n & 1) {
cout << "0\n";
return 0;
}
n /= 2;
ll fact_n = 1;
for (int i = 1; i <= n; ++i) {
(fact_n *= i) %= MOD;
}
ll fact_2n = fact_n;
for (int i = n + 1; i <= 2 * n; ++i) {
(fact_2n *= i) %= MOD;
}
ll ifact_n = powmod(fact_n, MOD - 2);
ll res = fact_2n * ifact_n % MOD * ifact_n % MOD * powmod(n + 1, MOD - 2) % MOD;
cout << res << "\n";
return 0;
}