Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:通过传递闭包的算法,环都是被求出来的,但是最后我们只累加出度和入度,无礼本身环的存在.真是一道不差的水题,水份刚刚好

Posted by huwenlin at 2009-03-03 11:03:53 on Problem 3660
In Reply To:通过传递闭包的算法,环都是被求出来的,但是最后我们只累加出度和入度,无礼本身环的存在.真是一道不差的水题,水份刚刚好 Posted by:gfedcba at 2009-03-02 21:13:05
>         int sum = 0;
> 	int ans = 0;
> 	for (i=1; i<=n; i++)
> 	{
> 		sum = 0;
> 		for (j=1; j<=n; j++)
> 		{
> 			if (i == j) // 不计算本身环
> 			{
> 				continue;
> 			}
> 			// 计算出度和入度的总和
> 			if (matrix[i][j])
> 			{
> 				sum++;
> 			}
> 		    if (matrix[j][i])
> 			{
> 				sum++;
> 			}
> 		}
> 		if (sum == n-1)
> 		{
> 			ans++;
> 		}
> 	}
> 	cout<<ans<<endl;

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator