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

最新文章

  1. 10.OC中retainCount返回值不准的原因
  2. portotype
  3. Python小练习三
  4. php数组的创建及操作
  5. material-singleinputform
  6. Gen_fsm行为实践与分析
  7. 从客户端中检测到有潜在危险的 Request.Form 值] 处理办法
  8. 图像处理中像素点的问题:unsigned char 和 char
  9. SQL Server 主动防止阻塞的 1 方法
  10. AIO5销售发货单numeric算数溢出报错:将numeric转换成数据类型numeric时出现算数溢出错误
  11. JAVA 动态代理原理和实现
  12. git操作:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! (警告:远程主机标识已更改!)
  13. OO第一单元表达式求导作业总结
  14. C_求质数
  15. poi excel 加粗
  16. JQuery Tree插件——zTree
  17. Selenium (1) —— Selenium安装与测试(101 Tutorial)
  18. string转换成char*
  19. 跳出python的各种坑(1)
  20. 查看当前session权限

热门文章

  1. SQL server 数据库基础语句 子查询 基础函数
  2. python 相关编码[转]
  3. js 分组数组
  4. 新建maven的pom.xml第一行出错的解决思路
  5. decompressedResponseImageOfSize:completionHandler:]_block_invoke
  6. Fiddler模拟POST请求
  7. 快学UIautomator之uiautomatorhelp使用
  8. java 去掉html/style/css等标签
  9. ZJOI2018游记Round2
  10. Django_外键查询和反查询