F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Permutation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 148    Accepted Submission(s): 41


Problem Description
Alice get a rooted tree that has N nodes. Every node has an unique id from 1 to N. Alice want to change the tree to a permutation. If for all nodes, all sons in its subtree is before it, we call the permutation is good. Now Alice wanna know the sum of the number of inversion pair of all good permutations. Output the answer mod 1000000007.
 

Input
The input contains multiple test cases.

For each test case, the first line contains two integers $N(1\leq N\leq 50)$,$ROOT(1\leq ROOT\leq N)$. Then N-1 lines, every line contains two integers U, V. The given tree is legal.
 

Output
For each test case output the answer mod 1000000007.
 

Sample Input
3 1 1 2 1 3 4 1 1 2 1 3 1 4
 

Sample Output
5 27
 

Author
ZSTU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:43:04, Gzip enabled