#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define whlie while #define mp make_pair #define pb push_back #define fi first #define se second #define inf 1001001001 #define mod 1000000007 #define FOR(i,a,b) for(int (i)=((int)a); (i)<((int)b); (i)++) // [a,b) #define rep(i,N) FOR((i), 0, ((int)N)) // [0,N) #define FORR(i,a,b) for(int (i)=((int)b) - 1; (i)>=((int)a); (i)--) #define repr(i,N) FORR((i), 0, ((int)N)) #define all(v) (v).begin(),(v).end() #define sz(v) ((int)(v).size()) #define vrep(v,it) for(auto it=v.begin();it pii; typedef pair pll; typedef vector vi; typedef vector vl; typedef vector vs; typedef vector vpii; typedef vector< vector > vvi; int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} ll gcd(ll a, ll b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);} int lcm(int a, int b){return (a / gcd(a,b)) * b;} ll lcm(ll a, ll b){return (a / gcd(a,b)) * b;} template inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template inline void _cin(C &c){cin >> c;} template inline void _cin(pair &p){cin >> p.fi; cin >> p.se;} template inline void _cout(const C &c){cout << c;} template inline void _cout(const pair &p){cout << p.fi << ' ' << p.se;} void in(){} template void in(T &t,U &...u){ _cin(t); in(u...);} void out(){cout << endl;} template void out(const T &t,U ...u){ _cout(t); if(sizeof...(u)) cout << ' '; out(u...);} void dbg_out(){cout << endl;} template void dbg_out(const T &t,U ...u){ _cout(t); if(sizeof...(u)) cout << ','; out(u...);} template inline void in(vector &v,int N=-1){if(sz(v) != 0){int M=(N == -1) ? sz(v) : N; rep(i,M) _cin(v[i]);}else{C c;rep(i,N) v.pb((_cin(c),c));}} template inline void in(C v[],int N){rep(i,N) _cin(v[i]);} template inline void out(const vector &v,int N=-1){int M=(N == -1) ? sz(v) : N; rep(i,M) {cout<<( (i)?" ":"" ); _cout(v[i]);} cout< inline void out(C v[],int N){rep(i,N) {cout<<( (i)?" ":"" ); _cout(v[i]);} cout< inline void vector_debug(const vector &v,int N=-1){int M=(N == -1) ? sz(v) : N; rep(i,M) {cout<<( (i)?", ":"" ); _cout(v[i]);} cout<<"}"< inline void vector_debug(C v[], int N){rep(i,N) {cout<<((i)?", ":""); _cout(*(v+i));} cout<<"}"< inline C vmax(const vector &v){C n=v[0]; rep(i,sz(v)) amax(n,v[i]); return n;} template inline C vmax(C v[], int N){C n=v[0]; rep( i , N ) amax(n,v[i]); return n;} template inline C vmin(const vector &v){C n=v[0]; rep(i,sz(v)) amin(n,v[i]); return n;} template inline C vmin(C v[], int N){C n=v[0]; rep( i , N ) amin(n,v[i]); return n;} template inline C vsum(const vector &v){C n=0; rep(i,sz(v)) n+=v[i]; return n;} template inline C vsum(C v[], int N){C n=0; rep( i , N ) n+=v[i]; return n;} const int dx[]={1,0,-1,0}; const int dy[]={0,1,0,-1}; //const int dx[]={1,1,1,0,-1,-1,-1,0}; const int dy[]={1,0,-1,-1,-1,0,1,1}; // ini(A,B,C) => int A,B,C; cin >> A >> B >> C; // in(A,B,C) => cin >> A >> B >> C; invi(v,N) =>vi v; rep(i,N) v.pb( (int x,cin >> x,x) ); // out(A,B,C) cout << A << ' ' << B << ' ' << C; // in,outともにベクトル・配列・pairに使用可能(ただしベクトル・配列は1つしか入れられない) // amax(x,y) bool関数 x Q; Q.push(src); A[src] = 1; // A[スタート地点]の深さ = 0 while(! Q.empty()){ int cur = Q.front(); trc(cur); Q.pop(); for(int x : v[cur]){ // 探索範囲 if(A[x] == -1){ // 条件 int dst = x; A[dst]=A[cur]+1; // dstの深さはA[cur]+1 Q.push(dst); // Qにdstを追加 } } } } int main(){ in(N); f(N); vdbg(fct,N+1); vvi v(N+1); rep(i,N-1){ ini(u,V); v[u].pb(V); v[V].pb(u); } vdbg(v[1]); vdbg(v[2]); bfs(1,v); ll ans = 0; for(int i=1; i<=N; i++){ ans = madd( ans, mdiv(fct[N] , A[i]) ); } out(ans); }