import java.math.BigInteger;
public class DUDU {
public static void main(String[] args) {
int n = 40;
for (int i = 5; i <= n; i++) {
long[][][][] E = new long[2 * n][2 * n + 3][5][4];
E[0][2][1][0] = 1;
for (int x = 1; x < 2 * n; x++) {
for (int s = (x + 1) % 2; s < x + 2; s += 2) {
for (int a = 0; a <= 2; a++) {
E[x][s + 1][a + 1][0] = E[x - 1][s][a + 1][0] + E[x - 1][s][a + 1][2];
E[x][s + 1][a + 1][1] = E[x - 1][s + 2][a + 1][0] + E[x - 1][s + 2][a + 1][1]
+ E[x - 1][s + 2][a + 1][3];
E[x][s + 1][a + 1][2] = E[x - 1][s][a][3] + E[x - 1][s][a + 1][1];
E[x][s + 1][a + 1][3] = E[x - 1][s + 2][a + 1][2];
}
}
}
BigInteger sum = BigInteger.ZERO;
for (int x = 0; x < 4; x++) {
sum = sum.add(BigInteger.valueOf(E[2 * n - 1][1][3][x]));
}
System.out.println("n=" + i + ": " + sum);
}
}
}
Comments
0 B
|👍
/👎