structEdge { int to, next; } e[maxn * 2]; int c1, head[maxn]; inlinevoidadd_edge(int u, int v){ e[c1].to = v; e[c1].next = head[u]; head[u] = c1++; }
int f[maxn]; voiddfs(int u, int fa){ f[u] = 1; for (int i = head[u]; ~i; i = e[i].next) { int v = e[i].to; if (v == fa) continue; dfs(v, u); f[u] += f[v]; } if (f[u] == k) f[u] = 0; }
voidwork(){ fill(head, head + maxn, -1); c1 = 0; cin >> n >> k; for (int i = 1; i < n; ++i) { int x, y; cin >> x >> y; add_edge(x, y); add_edge(y, x); } dfs(1, 0); cout << (!f[1] ? "YES\n" : "NO\n"); }