题目大意:求一个$n+1$个点的轮图的生成树个数,轮图的定义是有$n$点连成一个环,并且这$n$个点都向中心的一个点连边
题解:矩阵树定理,辗转相除法,用$python$解决高精
卡点:无
Python3 Code:
n = int(input()) n += 1 f = [[0 for i in range(n)] for i in range(n)] def addedge(a, b): global f f[a][b] -= 1 f[b][a] -= 1 f[a][a] += 1 f[b][b] += 1 for i in range(1, n): addedge(0, i) for i in range(1, n - 1): addedge(i, i + 1) addedge(n - 1, 1) ans = 1 for i in range(0, n - 1): for j in range(i + 1, n - 1): while f[j][i]: t = f[i][i] // f[j][i] for k in range(i, n - 1): f[i][k] -= t * f[j][k] f[i], f[j] = f[j], f[i] ans = -ans for i in range(0, n - 1): ans *= f[i][i]