2023夏-A-3 Rank of Binary Tree
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目描述
Here we define the rank of a binary tree as where is the number of nodes of degree for .
For example, given a tree shown by the figure, its rank is .

Given the inorder and preorder traversal sequences of a binary tree, you are supposed to calculate its rank.
输入格式
Each input file contains one test case. For each case, the first line contains a positive integer (), which is the total number of nodes in the tree. Then given in the following 2 lines are the inorder and preorder traversal sequences of the tree, respectively. All the keys in the tree are distinct positive integers in the range of int.
输出格式
For each case, print in a line the way we calculate the rank, and the integer part of the rank. The format is:
n1 * n2 / n0 = rank
样例
9
2 3 1 5 4 7 8 6 9
1 2 3 6 7 4 5 8 9
2 * 3 / 4 = 1
限制
对于所有的测试用例,限制为400 ms, 64 MB