0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 23:16:30 +00:00
OI-codes/Luogu/problem/P5908/P5908.cpp

35 lines
623 B
C++
Raw Normal View History

2020-11-05 00:12:33 +00:00
#include <bits/stdc++.h>
using namespace std;
int n, a, b, d, ans;
vector<int> g[100005];
bool vis[100005];
void dfs(int now, int dis) {
vis[now] = true;
if (dis == d) {
return;
}
for (int i = 0; i < g[now].size(); i++) {
if (!vis[g[now][i]]) {
ans++;
dfs(g[now][i], dis + 1);
}
}
return;
}
int main() {
memset(vis, 0x00, sizeof(vis));
cin >> n >> d;
for (int i = 1; i < n; i++) {
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
dfs(1, 0);
cout << ans << endl;
return 0;
}