HDU 1273 (stroll forest)

Basic question, a total of N nodes, there are two nodes the connection between the two, so there are N * (N-1) / 2 edges. Each traversal time have to go through N edges, it can take a total of (N-1) / 2 times.

#include <iostream>
using namespace std;

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

Keep up.

Published 206 original articles · won praise 1 · views 8990

Guess you like

Origin blog.csdn.net/Intelligence1028/article/details/104820738