-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray
More file actions
37 lines (29 loc) · 1.01 KB
/
Array
File metadata and controls
37 lines (29 loc) · 1.01 KB
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
37
import java.io.*;
public class Main {
static final long MOD = 1_000_000_007L;
static long modPow(long a, long e) {
long r = 1;
while (e > 0) {
if ((e & 1) == 1) r = r * a % MOD;
a = a * a % MOD;
e >>= 1;
}
return r;
}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine().trim());
int max = 2 * n;
long[] fact = new long[max + 1];
long[] invFact = new long[max + 1];
fact[0] = 1;
for (int i = 1; i <= max; i++)
fact[i] = fact[i - 1] * i % MOD;
invFact[max] = modPow(fact[max], MOD - 2);
for (int i = max; i > 0; i--)
invFact[i - 1] = invFact[i] * i % MOD;
long comb = fact[2 * n - 1] * invFact[n] % MOD * invFact[n - 1] % MOD;
long ans = (2 * comb % MOD - n + MOD) % MOD;
System.out.println(ans);
}
}