【玲珑杯 1051】【构造】My-graph
来源:互联网 发布:奥斯维辛集中营 知乎 编辑:程序博客网 时间:2024/05/29 14:48
传送门:http://www.ifrog.cc/acm/problem/1051
思路:
如果一个图有n个顶点,有∁2n条可能的边。显然,一个图要想和自己互补,它里面的连线数必然是 ∁2n2, 且其必须是偶数。即可以被4k 和
4k+1整除 的数。那么这个条件是充分的吗?
接下来,我们将会构造性地说明,对于上述的每一个 n ,顶点数为 n 的图都确实有可能和自己互补。当 n = 1 时,整个图只有 1 个顶点,没有任何连线,根据定义,它和它自己是互补的。当 n = 4 时,一条简单的“链”便满足要求:不妨把这 4 个顶点分别记作 x 、 y 、 z 、 w ,那么 x – y – z – w 的补图就是 y – w – x – z ,整个图的本质结构并未发生改变。
另外,对于任意一个有 k 个顶点的且与自己互补的图,在它外面添加一根由 4 个新顶点组成的链条 x – y – z – w ,再把顶点 x 与所有 k 个顶点都相连,把 w 也与所有 k 个顶点都相连。容易看出,整个图现在就有 k + 4 个顶点了,并且这个新的图也和自己是互补的。
因此,我们就可以从 n = 1 和 n = 4 的情形出发,借助上面的扩展方法,依次得到 n = 5, n = 8, n = 9, n = 12, … 的构造。
代码:
#include <iostream>#include <stdio.h> using namespace std;int main(){ int T; scanf("%d", &T); while(T--){ int n; scanf("%d", &n); if(n % 4 <= 1)puts("yes"); else puts("no"); } return 0;}
描述:
Time Limit:1s Memory Limit:64MByte
Submissions:359Solved:178
In graph theory, the inverse of a graph GG is a graph HH on the same vertices such that two distinct vertices of HH are adjacent if and only if they are not adjacent in GG.
My-graph is the graph that it's inverse graph is an isomorphism graph of itself.
(This is a example of My-graph has 5 nodes).
Now comes the problem: Do you have a way to make a My-graph that has nn nodes?
- 【玲珑杯 1051】【构造】My-graph
- 玲珑1051 My-graph
- 【玲珑学院 1051 - My-graph】
- “玲珑杯”ACM比赛 Round #4 F -- My-graph【图的同构(构造)】
- LonLife 1051 My-graph
- **1051 - My-graph-同构图
- 玲珑杯
- 【玲珑杯 1010 Alarm】
- 玲珑杯 1010 - Alarm
- 玲珑杯-【 chess play】
- 玲珑杯-【See car】
- 玲珑杯-1065-思维
- 玲珑杯-1058-dfs
- 玲珑杯 C -- Coco
- 玲珑杯-1071【思维】
- 玲珑杯-Boring Game
- “玲珑杯”Round #11
- 玲珑杯 1101
- Python中安装xlrd模块
- python入门常用功能小结
- java利用正则表达式获取一个网页中的所有邮箱地址
- structs2 文件下载
- 【我的Android进阶之旅】解决Android Studio启动时报错:Java 1.8 or later is required.
- 【玲珑杯 1051】【构造】My-graph
- 我读YOLO
- 注解
- 最短路径算法正确性和操作性闲杂谈-Dijkstra&Floyd算法
- 刘未鹏 - 为什么你现在就应该开始写博客
- python菜鸟的心得体会1
- UE4 设置Button触控区域为图片形状
- MyEclipse配置spket插件编写Extjs自动提示代码
- org.apache.jasper.JasperException: Unable to compile class for JSP