#P7513. [2017年杭电多校]Mystery
[2017年杭电多校]Mystery
Mystery
Problem Description
would like to find out everything about the binary tree. She has a full binary tree ,each point has different labels. regarding each point of tree , defines its height being the number of points which the shortest path from this point to a leaf has. each point has weight which be defined as . wants to paint every points by color ,Observing the following rules: $\bullet\ Y\ge 2\times \sum_{i\in leaf} B_i-\sum_{i\in T}B_i$ (define ) defines the contribution of the tree as . She wants to know how many legal methods can she paint the tree,which cause is multiple of . You need to print .
Input
4 positive integer,,,(,,,, is a prime number). means the tree has points.
Output
an integer showing .
Sample Input
2
8 10 7 11
34819237827249996 146 5 349
Sample Output
630072624
673102984
Source
2017 Multi-University Training Contest - Team 7