Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:通过传递闭包的算法,环都是被求出来的,但是最后我们只累加出度和入度,无礼本身环的存在.真是一道不差的水题,水份刚刚好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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator