摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 25#define maxl 100struct Candidate{ int num; int id;} can[maxn];int n, m;char name[maxn][maxl];char party[maxn][maxl];bool operator 阅读全文
posted @ 2011-09-08 19:55 undefined2024 阅读(132) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;#define eps 1.0E-8double xx1,xx2,yy1,yy2;double dist(double x1, double y1, double x2, double y2){ double x = abs(x1 - x2); double y = abs(y1 - y2); r 阅读全文
posted @ 2011-09-08 19:03 undefined2024 阅读(148) 评论(0) 推荐(0)
摘要: 最小路径覆盖题意:不是赤裸裸的最小路径覆盖(走遍所有的点),正常的最小路径覆盖中两个人走的路径不能有重复的点,而本题可以重复。分析:我们仍可将问题转化为最小路径覆盖。如果一个人需要经过另一个人走过的点的时候,让他直接从该点上空飞过去,越过该点,直接走下一个点。如果我们赋予每个人这种能力,那么求得的无重复点的最小路径覆盖结果,就是题目要求的结果,因为需要重复的地方只要飞过去,就可以不重复了。赋予这个能力的方法就是把所有点能间接到达的点全都改为直接到达。然后正常求最小路径覆盖即可。View Code #include <iostream>#include <cstdlib> 阅读全文
posted @ 2011-09-08 18:46 undefined2024 阅读(682) 评论(0) 推荐(1)
摘要: 动态规划View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;#define maxn 105#define maxm 450#define inf 0x3f3f3f3fint n;int v[maxn];int f[maxn][maxn * maxm];int sum;int main(){ //freopen("t.txt", "r", stdin); s 阅读全文
posted @ 2011-09-08 15:56 undefined2024 阅读(302) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int a, b, c;char st[50];int make(char *st){ int len = strlen(st); int ret = 0; for (int i = len - 1; i >= 0; i--) ret = ret * 10 + st[i] - '0'; return ret;}int 阅读全文
posted @ 2011-09-08 14:01 undefined2024 阅读(152) 评论(0) 推荐(0)
摘要: 排序题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 1005#define inf 0x3f3f3f3fstruct A{ int a, b; int v;} add[maxn * maxn];struct B{ int c, d; int v;} mns[maxn * maxn];int f[maxn];int 阅读全文
posted @ 2011-09-08 13:44 undefined2024 阅读(185) 评论(0) 推荐(1)
摘要: 二分图匹配View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;#define MAXN 105struct Point{ double x, y;} gopher[MAXN], hole[MAXN];int uN, vN, v, s;bool g[MAXN][MAXN];int xM[MAXN], yM[MAXN];bool chk[MAXN];bool 阅读全文
posted @ 2011-09-08 10:37 undefined2024 阅读(140) 评论(0) 推荐(0)
摘要: 解析几何在解析几何中,二分法是常用的。题意:给出x,y,c求?长度。分析:设两直角边为xx,yy。两对顶三角形相似 => yy/c=xx/(xx-c) => c = xx*yy/(xx+yy)然后二分查找所求长度即可。可以通过所求长度和x,y,计算出c,若c比真实的大则证明当前的查找值偏小。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cmath>#include <cstdio>usingnamespace std;# 阅读全文
posted @ 2011-09-08 10:14 undefined2024 阅读(207) 评论(0) 推荐(0)