Hdu 2800
来源:互联网 发布:windows xp sp2 编辑:程序博客网 时间:2024/06/16 01:48
Adding Edges
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 314 Accepted Submission(s): 216
Problem Description
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:
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:
Input
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.
Output
For each test case, output on a line the smallest possible value of the degree(1).
Sample Input
30
Sample Output
224300082010-05-08 10:31:21Accepted280046MS232K137 BC++chen
//n是奇数,算上A一共有n+1个点,所以某个点的最大的度数为n,因为要所有度数不一样,所以度数序列为1,2,……,n;先设一
//个点的度数为n,则它要和除了与它相对的点之外的所有点再连线,所以其它点的度数这时都为2,只有它的相对的点是1,所以这两
//个点的度数都确定。去掉这两个点后发现剩下的n-1个点的度数都是2,依次类推就可以找到第一个点的最小度数了,简化为公式就是
//(n+1)/2;
//这道题真让人崩溃,就是一个找规律的题。
//改成移位竟然比除以2还要慢
#include<iostream>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF&&n)
{
printf("%d/n",(n+1)>>1);
}
}
- Hdu 2800
- HDU 2800
- hdu 2800 Adding Edges
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- 经理=PD + Architect + PM + HR
- PKU ACM 1046
- 数据结构-栈(先进后出表)
- 栈的链式储存(不存在上溢)
- ASP.NET 连接数据库失败
- Hdu 2800
- Ballot evaluation
- 106条打造你成为交际大师
- PHP可变变量(Variable variables)的应用
- eclipse中关于jboss部署ejb,遇到报错的问题
- windows 编程笔记
- 想找几个人成立个小工作室,做些小软件什么的,有人有兴趣么?
- (应用推荐)ilock 来之 MMMOOO
- Linux 获取系统时间