题目大意:
给你
n
个背包,然后输入
解题思路:
显然对于这种包含关系我们很容易就想到了树上的关系,包含关系就是父亲与儿子的关系,然后在最外面的背包我们把他们都连在一个根节点上。然后一次操作就相当于找一棵子树。然后我们发现如果我们对同一个背包做两次操作相当于没有做,然后我们如果在初始状态上对地上的背包
i
做了一次操作,然后会发现地上只剩下
AC代码:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int n;
int main()
{
freopen("sgu238.in","r",stdin);
freopen("sgu238.out","w",stdout);
scanf("%d",&n);
printf("%d\n",n+(n>1));
fclose(stdin);
fclose(stdout);
return 0;
}