Hduoj2800【水题】
来源:互联网 发布:爱福窝软件 编辑:程序博客网 时间:2024/05/16 08:52
Adding Edges
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 768 Accepted Submission(s): 509
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
2
Source
HDU 2009-4 Programming Contest
#include<stdio.h>#include<string.h>int n; int main(){int i;while(scanf("%d", &n) != EOF && n){printf("%d\n", (n+1) >> 1);}return 0;}
题意:给出一对对互相带连线的点,现在要求给他们互相之间连线,要求除了A以外的任意2个点之间都不能都相同的边数,即度数,最后使得编号为1的点的度数最小,求这个最小的度数。
思路:这里总共有n+1个点,除了A以外有n个点,所以对于每个度数不同的点来说必定是从1~n的,那么我们假设某个点i的度数为n,因为它的对面的点已经占了一个度,所以我们必须从剩下的n-1个点与它相连,那么这剩下的n-2个点的度数都变成了2,除了i对面的那个点的度数为1,由于必定会有度数为1的点所以我们不能再动那个点。以此类推,由于1的对面是A,是不计入度数的,所以1能够取得的最小的度数就是n+1的一半。
0 0
- Hduoj2800【水题】
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- 水题:
- 水题
- 水题~
- 水题
- 水题
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- always模块合并写占用的逻辑资源和以及分开写的好处(未解决)
- 不是梦话,手机充一次电能用一年!
- 程序员,为什么千万不要重写代码?
- Zebra 打印机校准命令
- java.net.SocketException: Software caused connection abort: socket write error
- Hduoj2800【水题】
- 如何学习计算机网络
- 使用 Jersey 和 Apache Tomcat 构建 RESTful Web 服务
- hive查询报错误
- 常用Windows消息合集
- cocos2dx 3.x学习笔记(一)
- ScrollView嵌套GridView、ListView
- hdoj.1325 Is It A Tree?[【并查集】 2015/07/24
- ie兼容模式长期保存