Pagini recente » Cod sursa (job #3160874) | Cod sursa (job #1672680) | Cod sursa (job #2148537) | Cod sursa (job #2597662) | Cod sursa (job #100191)
Cod sursa(job #100191)
#include <stdio.h>
int i,j,k,l,t,n,a[100010];
int main()
{
freopen("zvon.in","r",stdin);
freopen("zvon.out","w",stdout);
scanf("%d",&t);
for (l=1;l<=t;++l)
{
scanf("%d",&n);
for (i=1;i<=n;++i)
a[i]=0;
for (k=1;k<n;++k)
{
scanf("%d %d",&i,&j);
a[i]++;
}
k=0;
j=0;
for (i=1;i<=n;++i)
{
if (a[i]-j>=0) k+=a[i]-j;
if (a[i]>0) j=a[i]-1;
}
printf("%d\n",k);
}
return 0;
}