HDU 1273(漫步森林)

基础题,共有 N 个结点,两两结点间有连线,所以有 N*(N-1)/2 条边。每遍历一次都需要经过 N 条边,所以一共能走 (N-1)/2 次。

#include <iostream>
using namespace std;

int main()
{
	int N;
	while (cin >> N)
	{
		if (N == 0)
			break;
		cout << (N - 1) / 2 << endl;
	}
	return 0;
}

继续加油。

发布了206 篇原创文章 · 获赞 1 · 访问量 8990

猜你喜欢

转载自blog.csdn.net/Intelligence1028/article/details/104820738
hdu