摘要:
题意:一圆环上有2n个点,求两两连线且不交叉的方法数。分析:catalan数令h(1)=1,h(0)=1,catalan数满足递归式: h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (其中n>=2) 另类递归式: h(n)=((4*n-2)/(n+1))*h(n-1); 该递推关系的解为: h(n)=C(2n,n)/(n+1) (n=1,2,3,...)它的适用情况有:1、取物2n个,物品分a,b两种,任意时刻手中的a物品数<b物品数,的方法数为h(n)。2、把(n+2)边形分割成若干个三角形组面积组合的方法数为h(n)。... 阅读全文
posted @ 2011-06-06 21:29
undefined2024
阅读(537)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;#define maxn 800char map[maxn][maxn];void make(int n){ int each = pow(double(3), n - 2); for (int i = 0; i < each; i++) for (int j = 0; j < eac 阅读全文
posted @ 2011-06-06 20:43
undefined2024
阅读(311)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 500004int f[maxn];bool vis[maxn * 10];int main(){// freopen("t.txt", "r", stdin); memset(vis, 0, sizeof(vis)); f[0] = 0; for (int i = 1; i 阅读全文
posted @ 2011-06-06 20:14
undefined2024
阅读(216)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <queue>using namespace std;struct Item{ int qnum, t, period; Item(int qq, int tt, int pp): qnum(qq), t(tt), period(pp) {}};bool operator < (const Item &a, const Item &am 阅读全文
posted @ 2011-06-06 20:04
undefined2024
阅读(295)
评论(0)
推荐(0)
摘要:
题意:给出一些平面上点的坐标,用其中的点做顶点,求其中能组成正方形的个数。分析:每次枚举两个点,用hash看另外两个点存不存在。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#define maxn 1005struct XPoint{ int x, y;} point[maxn];struct Hash{ XPoint p; Hash *next;} h[maxn];int n, ans;i 阅读全文
posted @ 2011-06-06 19:34
undefined2024
阅读(459)
评论(0)
推荐(0)