Description:
無根樹計數。
Solution:
序列一共有 個位置,每個位置有 個選擇,所以一共有 種方案。每種方案可以 種方案連邊,所以答案是 。
#include <bits/stdc++.h>
using namespace std;
const int P = 9999991;
int n;
long long ans = 1;
int main() {
scanf("%d", &n);
for(int i = 1; i < n - 1; ++i) {
ans = ans * n % P;
}
for(int i = 1; i < n; ++i) {
ans = ans * i % P;
}
printf("%lld\n", ans);
return 0;
}