摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1059http://poj.org/problem?id=1014多重背包这个题有两种AC的方法一种是采用多重背包的方法,但是这个方法会超时,所以就加了一个取模(这是错误的地方)来减少时间,这个方法可以AC,但却是错误的 12 0 0 0 0 1 这组数据就不能正确的出结果;View Code 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 u 阅读全文
posted @ 2011-11-25 20:56 LT-blogs 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 一道简单的并查集题目,刚开始还以为是搜索的题目,又加上读错了题目,纠结了一天,直到看了E_star的解题报告;思路:先按速从小到大排序,然后两个for循环,如果从第 i 条路到第 j 条路之间的所有路能够让 i 和 j 连通,那么,这就存在一条路,且这条路的舒适度就是 两者的差值。http://acm.hdu.edu.cn/showproblem.php?pid=1598View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring&g 阅读全文
posted @ 2011-11-24 22:35 LT-blogs 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 这个博客的第一个,是一个简单题。http://poj.org/problem?id=1716题意:找有最少的元素个数的集合使每个集合内都包括两点。思路:贪心,首先按右顶点排序,每次找这个区间已经有多少个在集合内了,分为一个和两个或零个三种情况,然后分别判断;View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstdlib> 5 #include<cstring> 6 using namespace std; 7 int 阅读全文
posted @ 2011-11-22 09:51 LT-blogs 阅读(118) 评论(0) 推荐(0) 编辑