UVA11387 - The 3-Regular Graph(推理)
来源:互联网 发布:seo站群计划书 编辑:程序博客网 时间:2024/04/30 07:01
题目链接
题意:给n个点,问是否能画出一个无向图,且每个顶点连接3条边,如果可以的话输出连接的边。
思路:当增加一条边时,总的无向图的度数会增加2,所以度数之和n*2为偶数。当n为奇数时,度数之和为奇数,所以不存在。当n为偶数时才符合条件。注意特判n为2时的情况。输出的话,就头尾相连,然后i与i+(n/2)相连。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int const MAXN = 105;int n;void outPut() { printf("%d\n", n * 3 / 2); for (int i = 1; i <= n; i++) { int a = i; int b = i + 1; if (b > n) b %= n; printf("%d %d\n", a, b); } for (int i = 1; i <= n / 2; i++) printf("%d %d\n", i, i + (n / 2));}int main() { while (scanf("%d", &n) && n) { if (n < 4 || n % 2) printf("Impossible\n"); else outPut(); } return 0;}
0 0
- UVA11387 - The 3-Regular Graph(推理)
- UVa11387 - The 3-Regular Graph
- UVA 11387 - The 3-Regular Graph(构造问题+推理证明)
- uva 11387 - The 3-Regular Graph(构造)
- UVA 11387 The 3-Regular Graph
- uva 11387——The 3-Regular Graph
- HDU6029-Graph Theory-图论简单推理
- hdu 5302 Connect the Graph(构造)
- Codeforces715B-Complete The Graph(最短路)
- poj2125:Destroying The Graph(网络流)
- POJ2125 Destroying The Graph(最小割求割点)
- Regular expression:The dot
- 中位数(rms2017模拟3-1)*【推理】
- Tower( rms模拟4-3 ) * *(推理)
- 3ds Max插件开发(三)The Scene Graph and Nodes 场景节点
- 3ds Max插件开发(四)The Scene Graph and Nodes 场景节点
- POJ2125:Destroying The Graph
- POJ2125 Destroying The Graph
- C++ list 类学习笔记
- c语言练习 10-4. 字符串循环左移(20)
- sublime text2的cocos2dx-lua插件安装
- 微软msmq
- CICS返回码参考
- UVA11387 - The 3-Regular Graph(推理)
- Android图片管理组件(双缓存+异步加载)
- 单例设计模式之个人见解
- theano库中function函数output和updates执行的先后顺序
- java方法参数
- 2014ECCV视觉跟踪录用文章
- IE6中用了float:left之后导致margin-left双倍边距的BUG解决方法
- 下雨效果
- 【iOS-cocos2d-X 游戏开发之一】在Mac下结合Xcode搭建Cocos2d-X开发环境&卸载Cocos2dx模版