From 0a58105cb92eaab63df6608c5194d053f8eb3586 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Tue, 13 Sep 2016 15:47:18 +0800 Subject: [PATCH] =?UTF-8?q?Create=202373=5Fsunny606=5F=E6=97=A0=E4=BC=98?= =?UTF-8?q?=E5=8C=96.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From http://blog.csdn.net/sunny606/article/details/7854362 --- POJ/2373_sunny606_无优化.cpp | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 POJ/2373_sunny606_无优化.cpp diff --git a/POJ/2373_sunny606_无优化.cpp b/POJ/2373_sunny606_无优化.cpp new file mode 100644 index 0000000..78c2b2b --- /dev/null +++ b/POJ/2373_sunny606_无优化.cpp @@ -0,0 +1,84 @@ +#include +#include +#define L 1001000 + +int a,b,n,l,inf,dp[L]; +int tree[4*L]; + +void updata(int *p, int rt, int l, int r,int pos, int k) +{ + if (l==r) { + p[rt]=k; + return ; + } + int mid=(l+r)>>1; + if (pos<=mid) updata(p,rt<<1, l, mid, pos, k); + else updata(p, rt<<1|1, mid+1, r, pos, k); + int lv=p[rt<<1]; + int rv=p[rt<<1|1]; + p[rt]=lv>1; + if(e<=mid) return query(p, rt<<1, l, mid, s, e); + if(s>mid) return query(p, rt<<1|1, mid+1, r, s, e); + int lv=query(p,rt<<1, l, mid, s,mid); + int rv=query(p,rt<<1|1, mid+1, r, mid+1, e); + return lv>1); + min = query(tree, 1, 1, l, pos-b, pos-a); + + if (dp[i]<=inf) { + //if(dp[i]>min+1) + dp[i]=min+1; + updata(tree,1,1,l,pos,dp[i]); + /*for(int j=a; j<=b; j++) { + int idx = i-2*j; + if(idx<0) break; + if ( dp[i]>dp[idx]+1 ) dp[i]=dp[idx]+1; + }*/ + } + } + if(dp[l]>=inf) return -1; + else return dp[l]; +} + +int main() +{ + while (scanf("%d%d", &n, &l)!=EOF) { + + scanf("%d%d", &a, &b); + inf = (l/a)+9; + for(int i=0; i<=l; i++) dp[i]=inf; + + for(int i=0; i