Submission #2873701
Source Code Expand
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200005,P=924844033,G=5;
int n,tot,nxt[2*N],fst[N],to[2*N],size[N],f[N],rf[N],c[N*4],d[N*4];
int pw(int a,int x)
{
int ans=1;
for(;x;x>>=1,a=1ll*a*a%P)
if(x&1)ans=1ll*ans*a%P;
return ans;
}
void dfs(int u,int fa)
{
size[u]=1;
for(int i=fst[u];i;i=nxt[i])
if(to[i]!=fa)
{
dfs(to[i],u);
size[u]+=size[to[i]];
}
if(fa)d[size[u]]++,d[n-size[u]]++;
}
void ntt(int *a,int n,int inv)
{
for(int i=0,j=0;i<n;i++)
{
if(i>j)swap(a[i],a[j]);
for(int k=n>>1;(j^=k)<k;k>>=1);
}
for(int i=2;i<=n;i<<=1)
{
int m=i>>1,wn=pw(G,(P-1)+inv*(P-1)/i);
for(int *p=a;p<a+n;p+=i)
{
int w=1;
for(int j=0;j<m;j++)
{
int t=1ll*w*p[m+j]%P;
p[m+j]=(p[j]-t)%P;
p[j]=(p[j]+t)%P;
w=1ll*w*wn%P;
}
}
}
if(inv==-1)
{
int t=pw(n,P-2);
for(int i=0;i<n;i++)a[i]=1ll*a[i]*t%P;
}
}
int main()
{
scanf("%d",&n);
for(int i=1,u,v;i<n;i++)
{
scanf("%d%d",&u,&v);
nxt[++tot]=fst[u];fst[u]=tot;to[tot]=v;
nxt[++tot]=fst[v];fst[v]=tot;to[tot]=u;
}
dfs(1,0);
for(int i=1;i<n;i++)d[i]*=-1;
d[n]=n;
for(int i=f[0]=1;i<=n;i++)f[i]=1ll*f[i-1]*i%P;
rf[n]=pw(f[n],P-2);
for(int i=n;i;i--)rf[i-1]=1ll*rf[i]*i%P;
for(int i=0;i<=n;i++)d[i]=1ll*d[i]*f[i]%P;
for(int i=0;i<=n/2;i++)swap(d[i],d[n-i]);
for(int i=0;i<=n;i++)c[i]=rf[i];
int l;
for(l=1;l<=n+n;l<<=1);
ntt(c,l,1),ntt(d,l,1);
for(int i=0;i<l;i++)c[i]=1ll*c[i]*d[i]%P;
ntt(c,l,-1);
for(int i=1;i<=n;i++)
{
int ans=1ll*c[n-i]*rf[i]%P;
printf("%d\n",(ans+P)%P);
}
return 0;
}
Submission Info
Submission Time
2018-07-21 12:23:00+0900
Task
F - Many Easy Problems
User
luogu_bot3
Language
C++14 (GCC 5.4.1)
Score
1900
Code Size
1552 Byte
Status
AC
Exec Time
184 ms
Memory
22528 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:59:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:62:22: 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
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
175 ms
14592 KB
doublestar1
AC
176 ms
14592 KB
doublestar2
AC
175 ms
14592 KB
doublestar3
AC
175 ms
14592 KB
doublestar4
AC
175 ms
14592 KB
example0
AC
2 ms
8320 KB
example1
AC
2 ms
8320 KB
example2
AC
2 ms
8320 KB
line0
AC
183 ms
22528 KB
line1
AC
184 ms
22528 KB
line2
AC
183 ms
22528 KB
line3
AC
183 ms
22528 KB
line4
AC
183 ms
22528 KB
maxrand0
AC
184 ms
14592 KB
maxrand1
AC
183 ms
14592 KB
maxrand10
AC
183 ms
14592 KB
maxrand11
AC
183 ms
14592 KB
maxrand12
AC
183 ms
14592 KB
maxrand13
AC
183 ms
14592 KB
maxrand14
AC
183 ms
14592 KB
maxrand15
AC
183 ms
14592 KB
maxrand16
AC
183 ms
14592 KB
maxrand17
AC
183 ms
14592 KB
maxrand18
AC
183 ms
14592 KB
maxrand19
AC
183 ms
14592 KB
maxrand2
AC
183 ms
14592 KB
maxrand3
AC
183 ms
14592 KB
maxrand4
AC
183 ms
14592 KB
maxrand5
AC
183 ms
14592 KB
maxrand6
AC
183 ms
14592 KB
maxrand7
AC
183 ms
14592 KB
maxrand8
AC
183 ms
14592 KB
maxrand9
AC
183 ms
14592 KB
rand0
AC
4 ms
8448 KB
rand1
AC
2 ms
8320 KB
rand2
AC
3 ms
8448 KB
rand3
AC
4 ms
8448 KB
rand4
AC
2 ms
8320 KB
rand5
AC
4 ms
8448 KB
rand6
AC
3 ms
8448 KB
rand7
AC
4 ms
8448 KB
rand8
AC
2 ms
8320 KB
rand9
AC
3 ms
8320 KB
star0
AC
173 ms
14592 KB
star1
AC
173 ms
14592 KB
star2
AC
173 ms
14592 KB
star3
AC
173 ms
14592 KB
star4
AC
177 ms
14592 KB