LinkedForwardStar Link[MAXM << 1]; int Head[MAXN]= {0}; int size = 0;
voidInsert(int u, int v){ Link[++ size].to = v; Link[size].next = Head[u];
Head[u] = size; }
int N;
LL power(LL x, int p){ p = (p + MOD - 1) % (MOD - 1); LL cnt = 1; while (p) { if (p & 1) cnt = cnt * x % MOD; x = x * x % MOD; p >>= 1; } return cnt; }
LL fact[MAXN]= {0}; LL C(int n, int m){ return fact[n] * power (fact[m], MOD - 2) % MOD * power (fact[n - m], MOD - 2) % MOD; }
LL f[MAXN][MAXN][MAXN]= {0}; int subsize[MAXN]= {0}; LL temp[MAXN][MAXN]= {0}; voidDFS(int root, int father){ subsize[root] = f[root][1][1] = 1; for (int p = Head[root]; p; p = Link[p].next) { int v = Link[p].to; if (v == father) continue; DFS (v, root); memset (temp, 0, sizeof (temp)); for (int i = 1; i <= subsize[root]; i ++) for (int j = 1; j <= subsize[root] - i + 1; j ++) if (f[root][i][j]) for (int k = 1; k <= subsize[v]; k ++) for (int l = 1; l <= subsize[v] - k + 1; l ++) { temp[i + k - 1][j + l] = (temp[i + k - 1][j + l] + f[root][i][j] * f[v][k][l] % MOD) % MOD; // select temp[i + k][j] = (temp[i + k][j] + f[root][i][j] * f[v][k][l] % MOD * l % MOD) % MOD; // do not select } memcpy (f[root], temp, sizeof (f[root])); subsize[root] += subsize[v]; } }
LL g[MAXN]= {0};
intgetnum(){ int num = 0; char ch = getchar ();
while (! isdigit (ch)) ch = getchar (); while (isdigit (ch)) num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();
intmain(){ N = getnum (); for (int i = 1; i < N; i ++) { int u = getnum (), v = getnum (); Insert (u, v), Insert (v, u); } DFS (1, 0); // 相似度 n - k for (int i = 1; i <= N; i ++) { LL base = power (1ll * N, i - 2); for (int j = 1; j <= N - i + 1; j ++) { g[N - i] = (g[N - i] + base * f[1][i][j] % MOD * j % MOD) % MOD; if (N - i == 1) cout << "Test: " << f[1][i][j] % MOD % MOD << endl; } } fact[0] = 1; for (int i = 1; i <= N; i ++) fact[i] = fact[i - 1] * i % MOD; for (int i = N - 1; i >= 0; i --) for (int j = i + 1; j < N; j ++) g[i] = (g[i] - g[j] * C (j, i) % MOD + MOD) % MOD; for (int i = 0; i < N; i ++) { if (i > 0) putchar (' '); output (g[i]); } puts ("");