Submission #7942941
Source Code Expand
#include<bits/stdc++.h>
#define mod 924844033
typedef long long ll;
ll gi(){
ll x=0,f=1;
char ch=getchar();
while(!isdigit(ch))f^=ch=='-',ch=getchar();
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f?x:-x;
}
int pow(int x,int y){
int ret=1;
while(y){
if(y&1)ret=1ll*ret*x%mod;
x=1ll*x*x%mod;y>>=1;
}
return ret;
}
int fact[200010],ifact[200010];
int C(int n,int m){if(n<m)return 0;return 1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int fir[200010],dis[400010],nxt[400010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int siz[200010];
void dfs(int x){
siz[x]=1;
for(int i=fir[x];i;i=nxt[i]){
if(siz[dis[i]])continue;
dfs(dis[i]);
siz[x]+=siz[dis[i]];
}
}
int A[524341],B[524341],rev[524341],N,lg;
const int G=19260817,iG=pow(G,mod-2);
void ntt(int*A,int N,int t){
for(int i=0;i<N;++i)if(i<rev[i])std::swap(A[i],A[rev[i]]);
for(int o=1;o<N;o<<=1){
int W=pow(t?G:iG,(mod-1)/(o<<1));
for(int*p=A;p!=A+N;p+=o<<1)
for(int i=0,w=1;i<o;++i,w=1ll*w*W%mod){
int t=1ll*p[i+o]*w%mod;
p[i+o]=(p[i]-t+mod)%mod;
p[i]=(p[i]+t)%mod;
}
}
if(!t){
int iN=pow(N,mod-2);
for(int i=0;i<N;++i)A[i]=1ll*A[i]*iN%mod;
}
}
int main(){
#ifdef XZZSB
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
int n=gi(),a,b;
fact[0]=1;for(int i=1;i<=n;++i)fact[i]=1ll*fact[i-1]*i%mod;
ifact[n]=pow(fact[n],mod-2);for(int i=n;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
dfs(1);
for(int i=2;i<=n;++i)++A[n-siz[i]],++A[siz[i]];
for(int i=1;i<=n;++i)A[i]=1ll*A[i]*fact[n-i]%mod;
for(int i=0;i<=n;++i)B[i]=ifact[i];
N=1;while(N<n*2+3)N<<=1,++lg;
for(int i=0;i<N;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<lg-1);
ntt(A,N,1),ntt(B,N,1);
for(int i=0;i<N;++i)A[i]=1ll*A[i]*B[i]%mod;
ntt(A,N,0);
for(int i=1;i<=n;++i)printf("%d\n",(1ll*n*C(n,i)-1ll*ifact[i]*A[n-i]%mod+mod)%mod);
return 0;
}
Submission Info
Submission Time
2019-10-12 11:43:27+0900
Task
F - Many Easy Problems
User
test12345
Language
C++14 (GCC 5.4.1)
Score
1900
Code Size
1894 Byte
Status
AC
Exec Time
186 ms
Memory
19840 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:68:83: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
for(int i=1;i<=n;++i)printf("%d\n",(1ll*n*C(n,i)-1ll*ifact[i]*A[n-i]%mod+mod)%mod);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1900 / 1900
Status
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
171 ms
14592 KB
doublestar1
AC
172 ms
14592 KB
doublestar2
AC
171 ms
14592 KB
doublestar3
AC
172 ms
14592 KB
doublestar4
AC
172 ms
14592 KB
example0
AC
3 ms
10496 KB
example1
AC
3 ms
10496 KB
example2
AC
3 ms
10496 KB
line0
AC
178 ms
19840 KB
line1
AC
178 ms
19840 KB
line2
AC
179 ms
19840 KB
line3
AC
178 ms
19840 KB
line4
AC
179 ms
19840 KB
maxrand0
AC
181 ms
14592 KB
maxrand1
AC
185 ms
14592 KB
maxrand10
AC
182 ms
14592 KB
maxrand11
AC
186 ms
14592 KB
maxrand12
AC
184 ms
14592 KB
maxrand13
AC
182 ms
14592 KB
maxrand14
AC
181 ms
14592 KB
maxrand15
AC
181 ms
14592 KB
maxrand16
AC
181 ms
14592 KB
maxrand17
AC
184 ms
14592 KB
maxrand18
AC
182 ms
14592 KB
maxrand19
AC
181 ms
14592 KB
maxrand2
AC
181 ms
14592 KB
maxrand3
AC
181 ms
14592 KB
maxrand4
AC
181 ms
14592 KB
maxrand5
AC
181 ms
14592 KB
maxrand6
AC
181 ms
14592 KB
maxrand7
AC
181 ms
14592 KB
maxrand8
AC
181 ms
14592 KB
maxrand9
AC
181 ms
14592 KB
rand0
AC
5 ms
10496 KB
rand1
AC
3 ms
10496 KB
rand2
AC
4 ms
10496 KB
rand3
AC
5 ms
10496 KB
rand4
AC
4 ms
10496 KB
rand5
AC
5 ms
10496 KB
rand6
AC
4 ms
10496 KB
rand7
AC
5 ms
10496 KB
rand8
AC
3 ms
10496 KB
rand9
AC
4 ms
10496 KB
star0
AC
169 ms
14592 KB
star1
AC
175 ms
14592 KB
star2
AC
169 ms
14592 KB
star3
AC
168 ms
14592 KB
star4
AC
168 ms
14592 KB