Submission #1694451


Source Code Expand

#include <algorithm>
#include <cstdio>

const int N=200005,M=1<<19,mo=924844033;
int a[M],b[M],rev[M],g[20][2],fst[N],fac[N],inv[N],n,tot=0,invn;
struct Edge{
	int to,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

int dfs(int x,int father){
	int sz=1;
	for (int i=fst[x];i;i=e[i].nxt)
		if (e[i].to!=father) sz+=dfs(e[i].to,x);
	if (x!=1) a[sz]++,a[n-sz]++;
	return sz;
}

void FFT(int *a,int n,int f){
	for (int i=0;i<n;i++)
		if (i<rev[i]) std::swap(a[i],a[rev[i]]);
	for (int i=1,t=0;i<n;i<<=1,t++){
		int wn=g[t][f];
		for (int j=0;j<n;j+=i<<1){
			int w=1;
			for (int k=0;k<i;k++,w=1ll*w*wn%mo){
				int x=a[j+k],y=1ll*w*a[j+k+i]%mo;
				a[j+k]=(x+y)%mo;
				a[j+k+i]=(x-y)%mo;
			}
		}
	}
	if (f)
		for (int i=0;i<n;i++) a[i]=1ll*a[i]*invn%mo;
}

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

void mul(int m){
	int L=0,n=1;
	for (;n<m;n<<=1) L++;
	invn=ksm(n,mo-2);
	for (int i=1;i<n;i++)
		rev[i]=rev[i>>1]>>1^((i&1)<<(L-1));
	int val0=ksm(5,(mo-1)/n),val1=ksm(val0,mo-2);
	for (int i=L-1;i>=0;i--){
		g[i][0]=val0;val0=1ll*val0*val0%mo;
		g[i][1]=val1;val1=1ll*val1*val1%mo;
	}
	FFT(a,n,0);FFT(b,n,0);
	for (int i=0;i<n;i++) a[i]=1ll*a[i]*b[i]%mo;
	FFT(a,n,1);
}

int main(){
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	dfs(1,0);
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i;i--) inv[i-1]=1ll*inv[i]*i%mo;
	for (int i=0;i<=n;i++){
		a[i]=1ll*a[i]*fac[n-i]%mo;
		b[i]=inv[i];
	}
	mul(n*2);
	for (int i=1;i<=n;i++){
		int ans=(1ll*fac[n]*inv[n-i]%mo*n-a[n-i])%mo*inv[i]%mo;
		printf("%d\n",(ans+mo)%mo);
	}
}

Submission Info

Submission Time
Task F - Many Easy Problems
User aufeas
Language C++14 (GCC 5.4.1)
Score 1900
Code Size 1825 Byte
Status AC
Exec Time 192 ms
Memory 21632 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:64:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d\n",&n);
                  ^
./Main.cpp:67:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d\n",&x,&y);
                        ^

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 182 ms 13696 KB
doublestar1 AC 181 ms 13696 KB
doublestar2 AC 180 ms 13696 KB
doublestar3 AC 180 ms 13696 KB
doublestar4 AC 180 ms 13696 KB
example0 AC 3 ms 8320 KB
example1 AC 3 ms 8320 KB
example2 AC 3 ms 8320 KB
line0 AC 190 ms 21632 KB
line1 AC 190 ms 21632 KB
line2 AC 190 ms 21632 KB
line3 AC 189 ms 21632 KB
line4 AC 189 ms 21632 KB
maxrand0 AC 187 ms 13696 KB
maxrand1 AC 189 ms 13696 KB
maxrand10 AC 192 ms 13696 KB
maxrand11 AC 192 ms 13696 KB
maxrand12 AC 187 ms 13696 KB
maxrand13 AC 192 ms 13696 KB
maxrand14 AC 191 ms 13696 KB
maxrand15 AC 191 ms 13696 KB
maxrand16 AC 187 ms 13696 KB
maxrand17 AC 190 ms 13696 KB
maxrand18 AC 187 ms 13696 KB
maxrand19 AC 189 ms 13696 KB
maxrand2 AC 187 ms 13696 KB
maxrand3 AC 191 ms 13696 KB
maxrand4 AC 191 ms 13696 KB
maxrand5 AC 192 ms 13696 KB
maxrand6 AC 188 ms 13696 KB
maxrand7 AC 189 ms 13696 KB
maxrand8 AC 188 ms 13696 KB
maxrand9 AC 188 ms 13696 KB
rand0 AC 5 ms 8448 KB
rand1 AC 3 ms 8320 KB
rand2 AC 4 ms 8448 KB
rand3 AC 5 ms 8448 KB
rand4 AC 3 ms 8320 KB
rand5 AC 5 ms 8448 KB
rand6 AC 4 ms 8448 KB
rand7 AC 5 ms 8448 KB
rand8 AC 3 ms 8320 KB
rand9 AC 4 ms 8320 KB
star0 AC 178 ms 13696 KB
star1 AC 178 ms 13696 KB
star2 AC 178 ms 13696 KB
star3 AC 179 ms 13696 KB
star4 AC 179 ms 13696 KB