405924: GYM102157 5 Tree Division

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

5. Tree Divisiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Given a tree of size $$$n$$$ and an integer $$$k$$$. Your task is to determine if the tree can be divided into k non-intersecting subtrees of the same size. Every node of the tree should belong to exactly one subtree.

Input

The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n, k \leq 10^5$$$), the number of nodes in the tree and the number of subtrees after dividing the tree, respectively.

Each of the following $$$n - 1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a_i,b_i \leq n$$$), representing an edge that connects the two nodes. It is guaranteed that the given graph is a tree.

Output

Print "Yes" if it is possible to divide the tree into $$$K$$$ subtrees of the same size. Otherwise print "No".

ExamplesInput
4 2
1 2
2 3
3 4
Output
Yes
Input
5 2
5 1
5 2
5 3
3 4
Output
No

加入题单

算法标签: