找规律推公式的题目,公式挺简单的,就是(2 * n)!/(n!)*(n!)*4^n不过因为有用到大数,还是用java比较方便
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void work(int n) {
BigInteger up = BigInteger.ONE;
for (int i = 2; i <= 2 * n; i++) {
up = up.multiply(BigInteger.valueOf(i));
}
BigInteger down = BigInteger.ONE;
for (int i = 1; i <= n; i++) {
down = down.multiply(BigInteger.valueOf(2 * i));
}
down = down.multiply(down);
BigInteger gcd = down.gcd(up);
System.out.println(up.divide(gcd) + "/" + down.divide(gcd));
}
public static void main(String[] args) {
int T;
Scanner cin = new Scanner(System.in);
T = cin.nextInt();
while (T-- > 0) {
int n = cin.nextInt();
work(n);
}
}
}