上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 182 下一页
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define maxn 50005int t, n;int f[maxn];bool cmp(const int &a, const int &b){ return abs(a) < abs(b);}void input( 阅读全文
posted @ 2012-07-09 14:04 undefined2024 阅读(180) 评论(0) 推荐(0)
摘要: 题意:给一棵n个节点的无根树,问去掉那一点可以使各连通分支中的节点数均<=n/2。分析:任意选定一个根,用自底向上的方法记录每棵子树的节点数。这样对于每个节点就可以通过它子树的节点数量迅速地判断它是否符合条件,别忘了还要判断它上面那个它祖宗所在的连通分支(节点数为n减去其各个子树的连通分支数再减1)。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespac 阅读全文
posted @ 2012-07-09 11:04 undefined2024 阅读(494) 评论(0) 推荐(0)
摘要: priority_queue的bfspriority_queue的bfs相当于使用了dijkstra的思想。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <queue>using namespace std;#define maxn 305struct Point{ int x, y, w;}s, t;int n, m;char map[maxn][maxn];bool vis[maxn][maxn] 阅读全文
posted @ 2012-07-09 11:00 undefined2024 阅读(293) 评论(0) 推荐(1)
摘要: dpf[i][j] = max(f[i + 1][j] + sum(i + 1,j) + v[i],f[i][j - 1] + sum(i,j - 1) + v[j])View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 2005int n;int v[maxn];int f[maxn][maxn];int sum[maxn];void input(){ scanf(&qu 阅读全文
posted @ 2012-07-06 19:32 undefined2024 阅读(329) 评论(0) 推荐(0)
摘要: 模拟题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 205int n, m, len;int f[maxn];char st[maxn];bool vis[maxn];int circle_num;int circle[maxn];int circle_length[maxn];char ans[maxn];void make(){ memset(vis, 0, s 阅读全文
posted @ 2012-07-06 14:16 undefined2024 阅读(178) 评论(0) 推荐(0)
上一页 1 ··· 52 53 54 55 56 57 58 59 60 ··· 182 下一页