Goodbye Wuxu 题解

考试被我一觉睡过去了

只能赛后补题

 

A.

给你一个 n 个点的完全图,求出它最多的边不相交的生成树个数,并输出每棵树

$n \leq 2000$

sol:


#include<bits/stdc++.h>#define LL long long#define rep(i,s,t) for(register int i = (s),i##end = (t); i <= i##end; ++i)#define dwn(i,s,t) for(register int i = (s),i##end = (t); i >= i##end; --i)using namespace std;inline int read(){ int x=0,f=1;char ch; for(ch=getchar();!isdigit(ch);ch=getchar())if(ch==-)f=-f; for(;isdigit(ch);ch=getchar())x=10*x+ch-0; return x*f;}int n,m;void pute(int x, int y){cout << x << " " << y << " ";}int main(){ m = n = read();if(n & 1)m--; cout << (n / 2) << endl; rep(i, 1, n/2) { int x = i, y = i + 1; pute(x, y); rep(j, 1, m/2-1) { x--;if(x == 0)x = m; pute(x, y); y++;if(y == m+1)y = 1; pute(x, y); } if(n & 1)pute(i, n); cout << endl; }}

View Code

 

相关文章