上一页 1 ··· 166 167 168 169 170 171 172 173 174 ··· 182 下一页
摘要: 简单题View Code #include <stdio.h>char st;int main(){ //freopen("D:\\t.txt", "r", stdin); while (scanf("%c", &st) != EOF) printf("%c", st); return 0;} 阅读全文
posted @ 2011-03-03 10:08 undefined2024 阅读(286) 评论(0) 推荐(0)
摘要: 用一个队列就可以解决,别忘了没答案要输出0。View Code #include <stdio.h>#define maxn 100005int f[maxn], n, s;void input() { int i; scanf("%d%d", &n, &s); for (i = 0; i < n; i++) scanf("%d", &f[i]);}int main() { //freopen("D:\\t.txt", "r", stdin); int t; scanf(& 阅读全文
posted @ 2011-03-03 09:40 undefined2024 阅读(241) 评论(0) 推荐(0)
摘要: 用c语言写的,memset不用包含头文件题意:矩阵上有一些小行星,占据了一些格子,我们每次操作可以清理一列中的所有小行星,也可以清理一行中的所有小行星,问最少进行多少次操作可以清理掉所有的小行星。分析:一个小行星,要么清理该行,要么该列。所以也就是每个小行星对应的行列中至少选择一样来清理。下面建图,如果我们把每行看成集合一中的点,每列看成集合二中的点,一个小行星看成是其对应行列的连线,那么也就是说不能存在某一条连线两边的点都没有被选中的情况。这恰好就是二分图最小点集覆盖的要求。最小点集覆盖==最大匹配。在这里解释一下原因。首先,最小点集覆盖一定>=最大匹配,因为假设最大匹配为n,那么我们 阅读全文
posted @ 2011-03-03 09:17 undefined2024 阅读(2841) 评论(1) 推荐(4)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("D:\\t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int a, b, c; scanf("%d%d%d", &a, & 阅读全文
posted @ 2011-03-01 10:48 undefined2024 阅读(253) 评论(0) 推荐(0)
摘要: spfa,说是边的价值=承重*单位价,实际上就是把到达每个结点所需经过的边的单位价之和乘以结点重量之积加起来即可。所以我们就是要让到达每个结点经过的边的单位价格之和最小。这就变成了最短路问题。这道题用栈超时,用队列能过。所以以后用spfa还是用队列的好。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 150005struct Edge{ int v, w, next; 阅读全文
posted @ 2011-03-01 10:34 undefined2024 阅读(694) 评论(0) 推荐(0)
上一页 1 ··· 166 167 168 169 170 171 172 173 174 ··· 182 下一页