如以下输入样例表示的树为:
请计算树的大小。
树的大小是指树中存在的节点的数量。
#include <iostream>
#include <set>
#define max_number 100000
using std::set;
int main() {
set<int> t;
int root;
scanf("%d", &root);
t.insert(1);
int a,b;
long long count = 0;
while(true)
{
scanf("%d %d", &a, &b);
// printf("%d %d\n",a,b);
if (a == 0)
{
break;
}
t.insert(a);
t.insert(b);
}
printf("%ld", t.size());
}