【构造】UVa 11387 The 3-Regular Graph
Description
输入n,构造一个n个点的无向图,使得每个点的度数都为3。不能有重边和自环,输出图或确定无解。
Solution
如果n为奇数,奇数*3=奇数,度数为奇,必无解。
考虑我们怎么构造一个图使得每个点度数为2?显然是直接连一个环。
再让他们度数为3,让点两两一连就行了。
秒之。
Code
注意n=2虽然是偶数但也无解。
#include<cstdio>
int main(){
int n;
while(scanf("%d",&n)==&&n){
if(n==||n%==){
printf("Impossible\n");
continue;
}
else{
printf("%d\n",n+n/);
for(int i=;i<n;i++)
printf("%d %d\n",i,i+);
printf("%d 1\n",n);
for(int i=;i<=n/;i++)
printf("%d %d\n",i,i+n/);
}
}
return ;
}
【构造】UVa 11387 The 3-Regular Graph的更多相关文章
- UVa 1479 (Treap 名次树) Graph and Queries
这题写起来真累.. 名次树就是多了一个附加信息记录以该节点为根的树的总结点的个数,由于BST的性质再根据这个附加信息,我们可以很容易找到这棵树中第k大的值是多少. 所以在这道题中用一棵名次树来维护一个 ...
- Codeforces Round #306 (Div. 2) D. Regular Bridge 构造
D. Regular Bridge Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...
- Codeforces 550D —— Regular Bridge——————【构造】
Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #306 (Div. 2)A B C D 暴力 位/暴力 暴力 构造
A. Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- cf550D Regular Bridge
Regular Bridge An undirected graph is called k-regular, if the degrees of all its vertices are equal ...
- cf#306D. Regular Bridge(图论,构图)
D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- python数据结构与算法——图的基本实现及迭代器
本文参考自<复杂性思考>一书的第二章,并给出这一章节里我的习题解答. (这书不到120页纸,要卖50块!!,一开始以为很厚的样子,拿回来一看,尼玛.....代码很少,给点提示,然后让读者自 ...
- Codeforces Round #306 (Div. 2) D
D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- paper: VG -- re-read
重点: 1.The constructed graph inherits several properties of the series in its structure. periodic se ...
随机推荐
- spring boot之入门配置(一)
yml.properties配置文件 yml相比properties配置文件,yml可以省略不必要的前缀,并且看起来更加的有层次感.推荐使用yml文件. @Value 根据配置文件的配置项获取对应的v ...
- Docker学习笔记【四】Docker 仓库
访问仓库,仓库是集中从存放镜像的地方.类似Maven. Docker Hub 目前由Docker官方维护的一个公共仓库,其中包括15000的镜像. 注册 在 https://hub.docker.co ...
- JFreeChart时间轴固定24小时每天刷新
Timeseries时间轴,设置x轴固定长度24小时 xAxis.setFixedAutoRange(3600000 * 2D), 再画出当天24点这一点 Date day = new Date(); ...
- OO开发思想:面向对象的开发方法(Object oriented,OO)
面向对象的开发方法(Object oriented,OO)认为是好文章吧,拿来分享一下(转载) 面向对象的开发方法(Object oriented,OO) 从事软件开发的工程 师们常常有这样 的体会: ...
- JMM规范
JMM规范: The rules for happens-before are: Program order rule. Each action in a thread happens-before ...
- SpringBoot功能持续更新
[定时任务] 1.启动总开关 @EnableScheduling加在@SpringBootApplication注解的start入口处,表示启动总开关 @SpringBootApplication @ ...
- FFPLAY的原理
概要 电影文件有很多基本的组成部分.首先,文件本身被称为容器Container,容器的类型决定了信息被存放在文件中的位置.AVI和Quicktime就是容器的例子.接着,你有一组流,例如,你经常有的是 ...
- Kali Linux Live USB初始化+使用日记
1.Live USB制作官方guide:Making a Kali Bootable USB Drive:https://docs.kali.org/downloading/kali-linux-li ...
- Mybatis批量更新数据库与批量插入数据库(以oracle为例)
一.批量更新 1.普通写法(一条记录update一次,性能比较差,容易造成阻塞.不建议使用) <update id="updateBatch" parameterType=& ...
- 第二课:Hadoop集群环境配置
一.Yum配置 1.检查Yum是否安装 rpm -qa|grep yum 2.修改yum源,我使用的是163的镜像源(http://mirrors.163.com/),根据自己的系统选择源, #进入目 ...