#P1332. Degree of Skewness
Degree of Skewness
Degree of Skewness
题目描述
Given a binary tree, let denotes the number of nodes with only a left child, and the number of nodes with only a right child. The degree of skewness is defined to be . Your job is to calculate for a given binary tree.
输入格式
Each input file contains one test case. For each case, the first lines gives a positive integer which is the number of nodes in the binary tree. The next two lines contain the post-order and in-order traversal sequences of the tree, respectively. The keys are integers from to . All the numbers in a line are seperated by a space.
输出格式
Print in a line the degree of skewness in the format:
Ds = nL - nR
样例 #1
样例输入 #1
7
1 2 7 5 4 3 6
1 2 3 4 7 5 6
样例输出 #1
2 = 3 - 1