pku 3660

View Code
#include<stdio.h>
#
include<string.h>
int map[105][105];
int main()
{
int n,m,a,b;
int i,j,k;
scanf(
"%d%d",&n,&m);
memset(map,0,sizeof(map));
for(i=0;i<m;i++)
{
scanf(
"%d%d",&a,&b);
map[a][b]
=1;
}
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(map[i][k]==1&&map[k][j]==1)
map[i][j]
=1;
int temp,count
=0;
for(i=1;i<=n;i++)
{
temp
=0;
for(j=1;j<=n;j++)
{
if(i==j) continue;
else if(map[j][i]||map[i][j])
temp
++;
}
if(temp==n-1)
count
++;
}
printf(
"%d\n",count);
return 0;
}

posted @ 2011-09-16 15:51  Because Of You  Views(158)  Comments(0Edit  收藏  举报