卡特兰数:
$C_{2n}^n-C_{2n}^{n-1} = \dfrac{C_{2n}^n}{n+1}$
package 数学;
import java.util.Scanner;
public class 满足条件的01序列 {
static int m = 1000000007;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
long res = 1;
for(int i = 1,j = 2*n; i <= n;i ++,j--) {
res = res * j % m;
res = res * qmi(i,m-2,m)%m;
}
System.out.println(res*qmi(n+1,m-2,m)%m);
}
private static long qmi(long a, int k, int m) {
long res = 1;
while(k!=0) {
if((k&1)==1) res = res * a %m;
a = a*a%m;
k>>=1;
}
return res;
}
}