Regular Bridge

An undirected graph is called k-regular, if the degrees of all its vertices are equal k. An edge of a connected graph is called a bridge, if after removing it the graph is being split into two connected components.

Build a connected undirected k-regular graph containing at least one bridge, or else state that such graph doesn't exist.

Input

The single line of the input contains integer k (1 ≤ k ≤ 100) — the required degree of the vertices of the regular graph.

Output

Print "NO" (without quotes), if such graph doesn't exist.

Otherwise, print "YES" in the first line and the description of any suitable graph in the next lines.

The description of the made graph must start with numbers n and m — the number of vertices and edges respectively.

Each of the next m lines must contain two integers, a and b (1 ≤ a, b ≤ n, a ≠ b), that mean that there is an edge connecting the vertices a and b. A graph shouldn't contain multiple edges and edges that lead from a vertex to itself. A graph must be connected, the degrees of all vertices of the graph must be equal k. At least one edge of the graph must be a bridge. You can print the edges of the graph in any order. You can print the ends of each edge in any order.

The constructed graph must contain at most 106 vertices and 106 edges (it is guaranteed that if at least one graph that meets the requirements exists, then there also exists the graph with at most 106 vertices and at most 106 edges).

Example

Input
1
Output
YES
2 1
1 2

Note

In the sample from the statement there is a suitable graph consisting of two vertices, connected by a single edge.

题意是要搞出个无向图,至少包含一条边是桥,而且每个点度数都是k

显然方便的构造是桥的两边是对称的

假如有两个联通块A,B通过一个桥联通,那么A和B之间除了桥以外不能有其他边。

考虑A块,假设有n个点,除去有一个点连出去一个桥,A块中其他边带来的度数之和应当是nk-1。

显然一条边一次带来2的度数,那么nk-1是偶数,nk是奇数,n、k都是奇数。

因此对于k是偶数的肯定无解

然后就是瞎鸡儿构造时间(不过为什么我看标答的点比我构造的少这么多)

假设A块的s点连了桥,那么s还需要连恰好k-1个点,标号成1~k-1,因为k是奇数所以k-1是偶数

然后对k-1个点两两分组,每组两个点a,b现在都只和s连上,再新建k-1个点,a和b都分别和k-1个新点连上,这样a和b度数都是k

新的k-1个点再两两连上变成完全图,这样每个新点都和k-2个其他新点连上,加上a和b恰好度数为k

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define pi 3.1415926535897932384626433832795028841971
#define mod 100007
using namespace std;
inline LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int k,n,m;
inline void put(int a,int b)
{
printf("%d %d\n%d %d\n",a,b,a+n/,b+n/);
}
int main()
{
k=read();
if (k%==){puts("NO");return ;}
puts("YES");
n=*(k+(k-)/*(k-));m=*(k-+(k-)/*((k-)+k*(k-)/))+;
printf("%d %d\n1 %d\n",n,m,+n/); for (int i=;i<=k;i++)put(,i);
int cnt=k;
for (int i=;i<=(k-)/;i++)
{
for (int j=;j<k;j++)
{
put(+i,++cnt);
put(+(k-)/+i,cnt);
}
for (int j=cnt-k+;j<=cnt;j++)
for (int l=j+;l<=cnt;l++)
put(j,l);
}
}

cf 550D

cf550D Regular Bridge的更多相关文章

  1. cf550D. Regular Bridge(构造)

    题意 给出一个$k$,构造一个无向图,使得每个点的度数为$k$,且存在一个桥 Sol 神仙题 一篇写的非常好的博客:http://www.cnblogs.com/mangoyang/p/9302269 ...

  2. D. Regular Bridge 解析(思維、圖論)

    Codeforce 550 D. Regular Bridge 解析(思維.圖論) 今天我們來看看CF550D 題目連結 題目 給你一個\(k\le100\),請構造出一個至少有一個Bridge的,每 ...

  3. cf#306D. Regular Bridge(图论,构图)

    D. Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. 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 ...

  5. Codeforces 550D —— Regular Bridge——————【构造】

     Regular Bridge time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  6. Codeforces 550 D. Regular Bridge

    \(>Codeforces \space 550 D. Regular Bridge<\) 题目大意 :给出 \(k\) ,让你构造出一张点和边都不超过 \(10^6\) 的无向图,使得每 ...

  7. 「日常训练」Regular Bridge(Codeforces Round 306 Div.2 D)

    题意与分析 图论基础+思维题. 代码 #include <bits/stdc++.h> #define MP make_pair #define PB emplace_back #defi ...

  8. codeforces #550D Regular Bridge 构造

    题目大意:给定k(1≤k≤100),要求构造一张简单无向连通图,使得存在一个桥,且每一个点的度数都为k k为偶数时无解 证明: 将这个图缩边双,能够得到一棵树 那么一定存在一个叶节点,仅仅连接一条桥边 ...

  9. Codeforces Round #306 (Div. 2)

    A. Two Substrings You are given string s. Your task is to determine if the given string s contains t ...

随机推荐

  1. 纪念一下我的第一个php扩展

    C扩展代码 生成 so扩展文件( 很多文章介绍 生成so时候 喜欢用 # phpize ./configure ...... 刚开始掉进坑里面出不来 就是因为把这两个命令看成了一个 phpize ./ ...

  2. 说说三四月的app审核中的几个坑

    苹果的审核在3月异常严格,听说和换了部门领导有关(道听途说),恰逢三月公司新出了一个产品,我们的产品被苹果打回四五次,今天就在简书上把这些坑填下,也让遇到的朋友以后留意,也许是近期的最后一篇文章. 坑 ...

  3. 图片,二进制,oracle数据库

    图片在oracle数据库中一般以二进制存在,存储类型是blob,然而clob类型一般存储的是大于4000的字符,不能用来存储图像这样的二进制内容,下面展示一下实现图像,二进制,oracle 数据库的应 ...

  4. Shell脚本中时间处理

    Shell脚本中时间处理 1.脚本内容 #!/bin/bash #环境变量 #设置环境变量和sql文件格式相符 source /etc/profileexport LD_LIBRARY_PATH=&q ...

  5. 控制器生命周期方法(LifeCycle)

    1.init方法: 在init方法中实例化必要的对象(遵从LazyLoad思想) ‍init方法中初始化ViewController本身   2.loadView方法:    当view需要被展示而它 ...

  6. Sass基本数据类型和各类型的原生方法

    数据类型: 数字:1,2,3,11,10px (可以带单位) 字符串:"asd",'asd',asd (有引号和无引号都是字符串类型) 如 $name : zhang san ; ...

  7. centos7.2 安装nginx

    一.首先检查gcc编译器安装了没 二 首先安装必要的库(nginx 中gzip模块需要 zlib 库,rewrite模块需要 pcre 库,ssl 功能需要openssl库),检查一下是否已经安装了( ...

  8. 【php】 PHP 支持 9 种原始数据类型

    PHP 支持 9 种原始数据类型. 四种标量类型: boolean(布尔型) integer(整型) float(浮点型,也称作 double) string(字符串) 三种复合类型: array(数 ...

  9. python_列表——元组——字典——集合

    列表——元组——字典——集合: 列表: # 一:基本使用# 1.用途:存放多个值 # 定义方式:[]内以逗号为分隔多个元素,列表内元素无类型限制# l=['a','b','c'] #l=list([' ...

  10. python 学习总结5

    字符串类型及操作 一.字符串类型的表示 (1)字符串:由0个或多个字符组成的有序字符序列  例如:“请输入带有符号的温度值” 或者‘c’都是字符串 (2)字符串是字符的有序序列,可以对其中的字符进行索 ...