矩阵树定理的第二题
把
n
n
n轮状病毒的图建出来
套用矩阵树定理就行了
这辈子不可能写高精度
召唤python
不能直接把度数标出来 会wa1 得直接模拟建图过程
maxn = 107
deg = [[0 for i in range(maxn)] for j in range(maxn)]
D = [[0 for i in range(maxn)] for j in range(maxn)]
G = [[0 for i in range(maxn)] for j in range(maxn)]
L = [[0 for i in range(maxn)] for j in range(maxn)]
def det(m):
res = 1
for i in range(1, m):
for j in range(i+1, m):
while L[j][i] != 0:
tmp = L[i][i] // L[j][i]
res = -res
for k in range(i, m):
L[i][k] -= tmp * L[j][k]
L[i][k], L[j][k] = L[j][k], L[i][k]
res *= L[i][i]
return res
n = int(input())
n += 1
for i in range(1, n-1):
G[i][i+1] = G[i+1][i] = 1
D[i][i] += 1
D[i+1][i+1] += 1
G[1][n-1] += 1
G[n-1][1] += 1
D[n-1][n-1] += 1
D[1][1] += 1
for i in range(1, n+1):
G[i][n] = G[n][i] = 1
D[n][n] += 1
D[i][i] += 1
for i in range(1, n+1):
for j in range(1, n+1):
L[i][j] = D[i][j]-G[i][j]
print(det(n))