Submission #1295178


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 600005, P = 924844033, G = 5;
int n, head[MAXN], nxt[MAXN<<1], to[MAXN<<1], cnt;
inline void insert(int u, int v) { nxt[++cnt] = head[u]; to[cnt] = v; head[u] = cnt; }

int A[MAXN], B[MAXN], ans[MAXN], fac[MAXN], inv[MAXN], rev[MAXN], size[MAXN];
inline int QuickPow(int x, int k) {
	int res = 1;
	for(; k; k >>= 1, x = 1LL * x * x % P) if(k & 1) res = 1LL * res * x % P;
	return res;
}

inline void dfs(int u, int fa) {
	size[u] = 1;
	for(int v, i = head[u]; i; i = nxt[i]) if((v = to[i]) != fa) {
		dfs(v, u);
		size[u] += size[v];
		if(--A[size[v]] < 0) A[size[v]] += P;
	}
	if(--A[n-size[u]] < 0) A[n-size[u]] += P;
	if(++A[n] >= P) A[n] -= P;
}

inline void NTT(int* x, int len, int d) {
	for(int i = 0; i < len; ++i) rev[i] = rev[i>>1] >> 1 | ((i & 1) ? (len>>1) : 0);
	for(int i = 0; i < len; ++i) if(rev[i] > i) swap(x[i], x[rev[i]]);
	
	for(int h = 2; h <= len; h <<= 1) {
		int wn = QuickPow(G, (P - 1 + d * (P - 1) / h) % (P - 1));
		for(int j = 0; j < len; j += h) {
			int w = 1;
			for(int k = j; k < j + h / 2; ++k) {
				int u = x[k], v = 1LL * w * x[k+h/2] % P;
				x[k] = (u + v) % P;
				x[k+h/2] = (u - v + P) % P;
				w = 1LL * w * wn % P;
			}
		}
	}
	if(d > 0) return;
	int Inv = QuickPow(len, P - 2);
	for(int i = 0; i < len; ++i) x[i] = 1LL * x[i] * Inv % P;
}

inline void Mul() {
	int len = n << 1 | 1;
	while(len != (len&-len)) len += (len&-len);
	NTT(A, len, 1); NTT(B, len, 1);
	for(int i = 0; i < len; ++i) A[i] = 1LL * A[i] * B[i] % P;
	NTT(A, len, -1);
	for(int i = 1; i <= n; ++i) ans[i] = 1LL * inv[i] * A[n+i] % P;
}

int main() {
	scanf("%d", &n);
	for(int u, v, i = n; --i; ) {
		scanf("%d%d", &u, &v);
		insert(u, v);
		insert(v, u);
	}
	dfs(1, 0);
	
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; ++i) {
		fac[i] = 1LL * i * fac[i-1] % P;
		inv[i] = 1LL * (P - P / i) * inv[P % i] % P;
	}
	for(int i = 2; i <= n; ++i) inv[i] = 1LL * inv[i] * inv[i-1] % P;
	for(int i = 0; i <= n; ++i) {
		A[i] = 1LL * A[i] * fac[i] % P;
		B[i] = inv[n-i];
	}
	
	Mul();
	
	for(int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}

Submission Info

Submission Time
Task F - Many Easy Problems
User wby
Language C++14 (GCC 5.4.1)
Score 1900
Code Size 2250 Byte
Status AC
Exec Time 194 ms
Memory 29568 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:58:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:60:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &u, &v);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1900 / 1900
Status
AC × 3
AC × 48
Set Name Test Cases
Sample example0, example1, example2
All doublestar0, doublestar1, doublestar2, doublestar3, doublestar4, example0, example1, example2, line0, line1, line2, line3, line4, maxrand0, maxrand1, maxrand10, maxrand11, maxrand12, maxrand13, maxrand14, maxrand15, maxrand16, maxrand17, maxrand18, maxrand19, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, star0, star1, star2, star3, star4
Case Name Status Exec Time Memory
doublestar0 AC 184 ms 25344 KB
doublestar1 AC 183 ms 25344 KB
doublestar2 AC 184 ms 25344 KB
doublestar3 AC 183 ms 25344 KB
doublestar4 AC 183 ms 25344 KB
example0 AC 4 ms 18560 KB
example1 AC 4 ms 18560 KB
example2 AC 4 ms 18560 KB
line0 AC 189 ms 29440 KB
line1 AC 189 ms 29440 KB
line2 AC 189 ms 29568 KB
line3 AC 189 ms 29440 KB
line4 AC 190 ms 29440 KB
maxrand0 AC 192 ms 25344 KB
maxrand1 AC 193 ms 25344 KB
maxrand10 AC 192 ms 25344 KB
maxrand11 AC 192 ms 25344 KB
maxrand12 AC 193 ms 25344 KB
maxrand13 AC 193 ms 25344 KB
maxrand14 AC 193 ms 25344 KB
maxrand15 AC 193 ms 25344 KB
maxrand16 AC 192 ms 25344 KB
maxrand17 AC 193 ms 25344 KB
maxrand18 AC 192 ms 25344 KB
maxrand19 AC 194 ms 25344 KB
maxrand2 AC 192 ms 25344 KB
maxrand3 AC 192 ms 25344 KB
maxrand4 AC 193 ms 25344 KB
maxrand5 AC 192 ms 25344 KB
maxrand6 AC 193 ms 25344 KB
maxrand7 AC 193 ms 25344 KB
maxrand8 AC 193 ms 25344 KB
maxrand9 AC 193 ms 25344 KB
rand0 AC 6 ms 18688 KB
rand1 AC 4 ms 18560 KB
rand2 AC 5 ms 18560 KB
rand3 AC 6 ms 18688 KB
rand4 AC 4 ms 18560 KB
rand5 AC 6 ms 18688 KB
rand6 AC 5 ms 18560 KB
rand7 AC 6 ms 18688 KB
rand8 AC 4 ms 18560 KB
rand9 AC 5 ms 18560 KB
star0 AC 185 ms 25344 KB
star1 AC 181 ms 25344 KB
star2 AC 182 ms 25344 KB
star3 AC 182 ms 25344 KB
star4 AC 182 ms 25344 KB