Submission #1807618


Source Code Expand

#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define next nex
using namespace std;
const int MAXN = 524290;
const int MOD = 924844033;
int a[MAXN], b[MAXN];
int n, m, i, j, k, x, y;
int size[MAXN];
int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN];
int bit[MAXN], f[MAXN];
inline int get()
{
	char c;
	while ((c = getchar()) < 48 || c > 57);
	int res = c - 48;
	while ((c = getchar()) >= 48 && c <= 57)
		res = res * 10 + c - 48;
	return res;
}
inline void add(int x, int y)
{
	next[++t] = first[x]; first[x] = t; go[t] = y;
}
inline void dfs(int now, int las)
{
	size[now] = 1;
	for(int i = first[now]; i; i = next[i])
		if (go[i] != las) dfs(go[i], now), size[now] += size[go[i]];
	a[n - size[now]] --;
	a[n] ++;
	for(int i = first[now]; i; i = next[i])
		if (go[i] != las) a[size[go[i]]] --;
}
inline int ksm(int x, int y, int z)
{
	int b = 1;
	while (y)
	{
		if (y & 1) b = 1ll * b * x % z;
		x = 1ll * x * x % z;
		y >>= 1;
	}
	return b;
}
inline int ntt_init(int m)
{
	int n = 1, nn = 0;
	while (n <= m) n <<= 1, nn ++;
	int g = ksm(5, (MOD - 1) / n, MOD);
	f[0] = 1;
	for(int i = 1; i < n; i ++)
		f[i] = 1ll * f[i - 1] * g % MOD, bit[i] = (bit[i >> 1] >> 1) | ((i & 1) << nn - 1);
	return nn;
}
inline void ntt(int *a, int nn, int ty)
{
	int n = 1 << nn;
	for(int i = 0; i < n; i ++)
		if (i < bit[i]) swap(a[i], a[bit[i]]);
	for(int k = 1; k <= nn; k ++)
	{
		int len = 1 << k, wn = (ty == 1) ? f[n / len] : f[n - n / len];
		for(int j = 0; j < n; j += len)
		{
			int m = len >> 1, w = 1;
			for(int i = j; i < j + m; i ++)
			{
				int l = a[i], t = 1ll * a[i + m] * w % MOD;
				a[i] = (l + t) % MOD;
				a[i + m] = (l - t + MOD) % MOD;
				w = 1ll * w * wn % MOD;
			}
		}
	}
}
int main()
{
	cin >> n;
	for(i = 1; i < n; i ++)
	{
		x = get(); y = get();
		add(x, y);
		add(y, x);
	}
	int nn = ntt_init(n << 1), N = 1 << nn;
	dfs(1, 0);
	for(i = 1; i <= n; i ++)
		if (a[i] < 0) a[i] += MOD;
	pre[0] = 1;
	for(i = 1; i < N; i ++)
		pre[i] = 1ll * pre[i - 1] * i % MOD, a[i] = 1ll * a[i] * pre[i] % MOD;
	for(i = 0; i <= n; i ++)
		b[i] = ksm(pre[n - i], MOD - 2, MOD);
	ntt(a, nn, 1);
	ntt(b, nn, 1);
	for(i = 0; i < N; i ++)
		a[i] = 1ll * a[i] * b[i] % MOD;
	ntt(a, nn, -1);
	int po = ksm(N, MOD - 2, MOD);
	for(i = 0; i < N; i ++)
		a[i] = 1ll * a[i] * po % MOD;
	for(i = n + 1; i <= n + n; i ++)
		printf("%d\n", 1ll * a[i] * ksm(pre[i - n], MOD - 2, MOD) % MOD);
}

Submission Info

Submission Time
Task F - Many Easy Problems
User diaosipan
Language C++14 (GCC 5.4.1)
Score 1900
Code Size 2553 Byte
Status AC
Exec Time 251 ms
Memory 24704 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:108:66: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   printf("%d\n", 1ll * a[i] * ksm(pre[i - n], MOD - 2, MOD) % MOD);
                                                                  ^

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 235 ms 20732 KB
doublestar1 AC 234 ms 20608 KB
doublestar2 AC 235 ms 20608 KB
doublestar3 AC 235 ms 20608 KB
doublestar4 AC 237 ms 20608 KB
example0 AC 4 ms 16640 KB
example1 AC 4 ms 16640 KB
example2 AC 4 ms 16640 KB
line0 AC 242 ms 24704 KB
line1 AC 242 ms 24704 KB
line2 AC 242 ms 24704 KB
line3 AC 242 ms 24704 KB
line4 AC 242 ms 24704 KB
maxrand0 AC 246 ms 20608 KB
maxrand1 AC 247 ms 20608 KB
maxrand10 AC 248 ms 20736 KB
maxrand11 AC 245 ms 20608 KB
maxrand12 AC 249 ms 20608 KB
maxrand13 AC 246 ms 20608 KB
maxrand14 AC 249 ms 20608 KB
maxrand15 AC 246 ms 20608 KB
maxrand16 AC 246 ms 20608 KB
maxrand17 AC 251 ms 20608 KB
maxrand18 AC 246 ms 20608 KB
maxrand19 AC 248 ms 20608 KB
maxrand2 AC 248 ms 20608 KB
maxrand3 AC 246 ms 20608 KB
maxrand4 AC 246 ms 20608 KB
maxrand5 AC 246 ms 20608 KB
maxrand6 AC 246 ms 20608 KB
maxrand7 AC 246 ms 20608 KB
maxrand8 AC 246 ms 20608 KB
maxrand9 AC 246 ms 20608 KB
rand0 AC 7 ms 16640 KB
rand1 AC 4 ms 16640 KB
rand2 AC 6 ms 16640 KB
rand3 AC 7 ms 16640 KB
rand4 AC 5 ms 16640 KB
rand5 AC 7 ms 16640 KB
rand6 AC 6 ms 16640 KB
rand7 AC 7 ms 16640 KB
rand8 AC 5 ms 16640 KB
rand9 AC 6 ms 16640 KB
star0 AC 231 ms 20608 KB
star1 AC 231 ms 20608 KB
star2 AC 231 ms 20608 KB
star3 AC 231 ms 20608 KB
star4 AC 231 ms 20608 KB