首页 > ACM题库 > HDU-杭电 > HDU 2800-HOJ-Adding Edges[解题报告]C++
2014
02-17

HDU 2800-HOJ-Adding Edges[解题报告]C++

Adding Edges

问题描述 :

There are N+1 points on the plane, number A,1,2…N. N is an odd integer. Initially, there exist (N+1)/2 edges, as shown in the picture below.

Now your mission is add some edges to the graph, makes that
① degree(i) != degree(j), (i != j, 1 <= i, j <= N).
② degree(1) as small as possible.
For example, when N = 3, there are two possible answers:

输入:

Each test case contains a single odd integer N(N<=10^6), indicating the number of points. The input is terminated by a set starting with N = 0.

输出:

Each test case contains a single odd integer N(N<=10^6), indicating the number of points. The input is terminated by a set starting with N = 0.

样例输入:

3
0

样例输出:

2

#include<stdio.h>
int main()
{
int n;
while(scanf("%d",&n),n)
printf("%d\n",n/2+1);
}

  1. 第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。第2题,TCP不支持多播,多播和广播仅应用于UDP。所以B选项是不对的。

  2. 可以根据二叉排序树的定义进行严格的排序树创建和后序遍历操作。如果形成的排序树相同,其树的前、中、后序遍历是相同的,但在此处不能使用中序遍历,因为,中序遍历的结果就是排序的结果。经在九度测试,运行时间90ms,比楼主的要快。

  3. [email protected]