摘要:
模拟View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;char st[100];bool vis[300];int main(){ //freopen("t.txt", "r", stdin); bool first = true; memset(vis, 0, sizeof(vis)); vis['A'] = true; vis[' 阅读全文
posted @ 2011-09-30 18:36
undefined2024
阅读(201)
评论(0)
推荐(0)
摘要:
模拟题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxl 1005char st[maxl];char ans[maxl];void work(){ int len = strlen(st); int i = 0; int l = 0; int r; while (l < len) { r = l + 1; if (r < len && st[ 阅读全文
posted @ 2011-09-30 17:54
undefined2024
阅读(182)
评论(0)
推荐(0)
摘要:
最小生成树View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;#define maxn 800#define maxm 1000struct Point{ int x, y;}point[maxn];struct Edge{ int a, b;}edge[maxn * maxn];int n, m;in 阅读全文
posted @ 2011-09-30 17:10
undefined2024
阅读(562)
评论(0)
推荐(0)
摘要:
题意:给定n,问有n个点的连通图有多少种,每个点是不同的。分析:求出有n个点的图有多少种,求出不连通的有多少种,相减即可。求有n个点的不连通图时,枚举第n个点所在的连通分支有几个点,有k个点的话,除去第n点,还要选k-1个点,有C(n - 1, k -1)种选法。剩余n-k个点,这n-k个点随意构图,每两点间要么有边,要么没边,两种选择。有2^C(n-k,2)种情况。则用C(n - 1, k -1)乘以2^C(n-k,2)再乘以k个点构成连通图的情况总数,这样规模为n的问题转化为规模为k的子问题。dp处理即可。View Code import java.io.*;import java.uti 阅读全文
posted @ 2011-09-30 15:41
undefined2024
阅读(586)
评论(0)
推荐(0)