微软hihoCoder
文章平均质量分 77
Dr-rong
这个作者很懒,什么都没留下…
展开
-
hihoCoder 二分·二分查找之k小数
与之前二分查找一个数是否在序列中道理是一样的 // hiho37week.cpp : Defines the entry point for the console application. // #include #include #include //#define DEBUG using namespace std; int findK(int start, int end, in原创 2015-03-20 15:53:27 · 841 阅读 · 0 评论 -
hihoCoder 1038 01背包
最经典的动态规划题目,注意这里将二维数组压缩成了一维数组来进行计算 // hiho1038.cpp : Defines the entry point for the console application. // #include #include #include #include //#define DEBUG using namespace std; int main() { #if原创 2015-03-20 18:37:54 · 345 阅读 · 0 评论 -
hihoCoder 1128 二分·二分查找
二分查找适用于“有序”的情况,即一次能排除一半备选答案。在本题中,当数列无序时,我们不能直接利用二分查找,但是,我们可以利用求第k小数的思路,即用partition一次排除一半。这里的partition同quick-sort中的partition是一样的,原理很简单,但实现起来要注意细节,比如指针的推进,元素的交换。 #include #include #include #include //#原创 2015-03-20 10:40:59 · 617 阅读 · 0 评论 -
hihoCoder 1043 完全背包
可以直接在0-1背包的基础上进行扩展,得到一个比较naive的解法 // hiho1043.cpp : Defines the entry point for the console application. // #include #include #include #include //#define DEBUG using namespace std; int main() { #i原创 2015-03-20 19:23:06 · 374 阅读 · 0 评论