2020-02-12 08:40:12

// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
int X=0,w=1; char c=getchar();
while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
return X*w;
}

const int N=5000+10;
const int mod=1e9+7;

struct edge { int v,nxt; } e[N<<1];

inline void addEdge(int u,int v) {
static int e_cnt=0;
}

int n,sz[N];
int f[N][N],g[N],tmp[N];

inline void dfs(int u,int fa) {
sz[u]=f[u][1]=1;
for (re int i=head[u];i;i=e[i].nxt) {
int v=e[i].v; if (v==fa) continue;
dfs(v,u);
for (re int j=1;j<=sz[u]+sz[v];++j) tmp[j]=0;
for (re int j=1;j<=sz[u];++j)
for (re int k=0;k<=sz[v];++k)
tmp[j+k]=(tmp[j+k]+1ll*f[u][j]*f[v][k])%mod;
sz[u]+=sz[v];
for (re int j=1;j<=sz[u];++j) f[u][j]=tmp[j];
}
for (re int i=2;i<=sz[u];i+=2)
f[u][0]=(f[u][0]-1ll*f[u][i]*g[i]%mod+mod)%mod;
}

int main() {
}