题意:你用k 个生成树构成一个完全图。

析:n 个点的完全图有n(n-1)/2个边,一个生成树有n-1个边,你有k 个生成树 即边数等于 K(n-1) ,即  n(n-1)/2 == k(n-1)   n = 2*k

所以2k 个边足够,你会发现在每个结点只能做一次开头或者结尾。然后找找规律就好。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define print(a) printf("%d\n", (a))
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
while(scanf("%d", &n) == 1){
m = n << 1;
printf("%d\n", m);
for (int i = 1; i <= n; ++i){
for (int j = i+1; j <= i + n; ++j) printf("%d %d\n",i, j);
for (int j = 1; j <= m-n-1; ++j) printf("%d %d\n",i+n, (i+n+j) % m == 0 ? m : (i+n+j)%m);
}
}
return 0;
}

最新文章

  1. 关于新版ADT创建项目时出现appcompat_v7的问题
  2. 通用访问 - 用“反射”来设计通用的通信协议,以及配套的SDK、工具
  3. hdu 4358 Boring counting dfs序+莫队+离散化
  4. Foix_Reader_6.0|PDF阅读器
  5. Unity3d多线程
  6. TFS错误 TF31004:在连接带xxx.xxx.xxx.xxx上的Team Foundation Server时遇到错误。请等待几分钟,然后重试。如果问题仍然存在,请与服务器管理员联系
  7. bzoj 3091 城市旅行(LCT+数学分析)
  8. HDU3695 - Computer Virus on Planet Pandora(AC自动机)
  9. 如何让有物理键的手机在ActionBar始终显示更多菜单menu键
  10. idea导出war包
  11. Linux中创建Daemon进程的三种方法
  12. Codeforces 903D Almost Difference
  13. 【转】Awk 命令学习总结、AWk命令系列学习(linux shell)
  14. Thread类的其他方法,同步锁,死锁与递归锁,信号量,事件,条件,定时器,队列,Python标准模块--concurrent.futures
  15. All about the “paper”
  16. Linux用户管理机制
  17. 清除li内a标签的float=left实现a标签在li内居中显示(ul内li不居中显示)
  18. NPOIHelp 按固定模板导出和直接导出
  19. 1128 - Greatest Parent---LightOj(LCA+离线算法)
  20. Oracle ora-12514监听程序当前无法识别连接描述中请求的错误

热门文章

  1. Android:图片中叠加文字,支持拖动改变位置
  2. POJ - 3233 Matrix Power Series (矩阵等比二分求和)
  3. goang Receiver &amp; interface
  4. TinyXML中类分析
  5. Python 包的制作(__init__.py)
  6. lodar
  7. busybox 终端支持 ctrl-r
  8. Android如果动态改变CursorAdapter Item个数
  9. 4408: [Fjoi 2016]神秘数
  10. OOalv 实现带出栏位描述