上一页 1 ··· 97 98 99 100 101 102 103 104 105 ··· 182 下一页
摘要: 题意:人和人之间如果满足4个条件的任意一条就不会成为夫妻,给定一些人,问从中最多能选多少人且保证任意两人不可能成为夫妻。分析:由于条件之一是性别相同则不能成为夫妻。我们根据性别把人划分为两个集合,每个人是一个结点构成二分图,若两个人可能成为夫妻则连一条边。(同性之间不能成为夫妻,所以同集合内无边,此图必定为二分图)。题目要求是选出最多的人,且任意两人之间无边。这就是求二分图的最大独立集。只要用总人数-最大匹配数即可。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include 阅读全文
posted @ 2011-07-26 13:47 undefined2024 阅读(319) 评论(0) 推荐(0)
摘要: 题意:一些人把一些箱子搬到楼上,这些人从各自的位置以相同的速度移动,有的向上,有的向下,向上的有箱子,向下的没箱子。到顶后放下箱子同速返回。若两人相遇,则向上的人把箱子给向下的人,同时两人同时转身向反方向走。问把箱子全搬上去要用多久。分析:我们可以忽略题中的人,认为只是一些箱子在移动,这些箱子的移动规律很明显,就是在不停地上升。我们还可以认为,两个人相遇并没有交换箱子,而是擦肩而过,这样对箱子和人都没有任何影响。因为a上b下,a,b相遇,就变成了a替b向上,b替a向下。所以本题就变成了所有的人轮流来一楼取箱子,取完了就向上走,走到楼顶,再走下来,再取。这样只要算出整体轮回了多少次,再加上多余的 阅读全文
posted @ 2011-07-25 21:05 undefined2024 阅读(154) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;int dcount;int n;char word[1005][50];int father[1005];int fa;int dir[1005][1005];int num[1005];int id[1005];void ins(char *st){ if (strcmp(st, &q 阅读全文
posted @ 2011-07-25 20:11 undefined2024 阅读(384) 评论(0) 推荐(0)
摘要: 题意:多项式求余分析:求余方法是,每次用被除式减去除式,直到不能减为止,具体做法是每次将除式乘以若干个x,使得除式与被除式的最高次项相同,然后用被除式减去除式。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#define maxn 2005int fn, gn, hn, en;int f[maxn], g[maxn], h[maxn], e[maxn];void input(){ scanf( 阅读全文
posted @ 2011-07-25 19:18 undefined2024 阅读(362) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1000int f[5];char st[maxn];char ans[maxn];int len;int group(char c){ if (c >= 'a' && c <= 'i') return 0; if (c >= 'j' 阅读全文
posted @ 2011-07-25 16:36 undefined2024 阅读(227) 评论(0) 推荐(0)
上一页 1 ··· 97 98 99 100 101 102 103 104 105 ··· 182 下一页