
其他 分治
文章平均质量分 75
yuhong_liu
这个作者很懒,什么都没留下…
展开
-
最大连续区间和(非环) -dp/分治
因为正要学 动态最大连续区间和 所以先用分治做一下静态的。。。 以前是dp做的o(n) 分治大约是是nlogn 分治: #include #include #include #include #include #include #include #include #include #include using namespace std; #include原创 2015-09-05 04:52:33 · 814 阅读 · 0 评论 -
poj2750-Potted Flower-动态求最大连续环区间和(线段树上分治+set维护)
http://poj.org/problem?id=2750 题意,给你n个数,首尾相接,让你求最大连续环区间和 首先知道这个最大连续和只有两种情况, 1是不跨越首尾的,这种直接求 2是跨越首尾的,显然最大连续和是跨越首尾的,那么最小连续区间和必然在1-n之间,所以我们只需要求最小连续和,然后sum-它就得到最大连续和 如果只求一次,可以dp就好了,但是由于每次动态更新单点,所以原创 2016-03-03 21:14:24 · 520 阅读 · 0 评论 -
hihoCoder挑战赛20-题目2 : 展胜地的鲤鱼旗 -DP/分治
http://hihocoder.com/contest/challenge20/problem/2 给一串括号,求有多少个子串合法 dp[i]表示以i为结尾的方案数,i位置显然只能是右括号啦 那么 dp[i]=dp[i-1]+1; 递推累计所有dp[i]就好 int main( ) { scanf("%s",ss+1); int n=strlen(ss+1)原创 2016-05-07 10:50:19 · 615 阅读 · 0 评论 -
Leetcode 4. Median of Two Sorted Arrays(分治法)
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 给两个有序表,O(log (m+原创 2017-03-11 01:47:01 · 520 阅读 · 0 评论