-->
当前位置:首页 > 题库

PROGRAMMING:Counting Leaves

Luz5年前 (2021-05-10)题库421
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.
### Input Specification:
The input consists of several test cases, each starts with a line containing $$0The input ends with $$N$$ being 0. That case must NOT be processed.
### Output Specification:
For each test case, you are supposed to count those family members who have no child for every seniority level starting from the root. The numbers must be printed in a line, separated by a space, and there must be no extra space at the end of each line.
For example, the first sample case represents a tree with only 2 nodes, where `01` is the root and `02` is its only child. Hence on the root `01` level, there is `0` leaf node; and on the next level, there is `1` leaf node. Then we should output `0 1` in a line.
### Sample Input:
```in
2 1
01 1 02
1 0
7 4
01 2 02 03
06 1 07
02 2 04 05
03 1 06
0 0
```
### Sample Output:
```out
0 1
one
0 0 2 1
```






answer:If there is no answer, please comment