上一页 1 ··· 86 87 88 89 90 91 92 93 94 ··· 99 下一页

2011年4月20日

记忆化搜索=搜索的形式+动态规划的思想(来自百度百科)

摘要: 记忆化搜索=搜索的形式+动态规划的思想记忆化搜索:算法上依然是搜索的流程,但是搜索到的一些解用动态规划的那种思想和模式作一些保存。一般说来,动态规划总要遍历所有的状态,而搜索可以排除一些无效状态。更重要的是搜索还可以剪枝,可能剪去大量不必要的状态,因此在空间开销上往往比动态规划要低很多。记忆化算法在求解的时候还是按着自顶向下的顺序,但是每求解一个状态,就将它的解保存下来,以后再次遇到这个状态的时候,就不必重新求解了。这种方法综合了搜索和动态规划两方面的优点,因而还是很有实用价值的。虽然不能使用传统意义上的动态规划解决本题,但动态规划的思想仍然能起到作用。搜索相对于动态规划最大的劣势无非就是重复 阅读全文

posted @ 2011-04-20 02:33 more think, more gains 阅读(232) 评论(0) 推荐(0) 编辑

2011年4月19日

hdu max sum

摘要: 这题跟求最大连续数列一样的,稍微不同的是只要把值改为标号就可以了。#include<stdio.h>#include<string.h>#include<stdlib.h>#include<debug.h>#define X 100001int A[X];int main( ){ int N,M,a,b,c,d,e,f,x,i,y,sum,len=0; Debug(); scanf("%d",&N); while(N--) { len++; memset(A,0,sizeof(A)); scanf("%d&q 阅读全文

posted @ 2011-04-19 20:19 more think, more gains 阅读(188) 评论(0) 推荐(0) 编辑

hdu 命运

摘要: 这题一看思路跟数塔,天上掉馅饼一样,从后面往前推,不断比较,更新,就ok了。。发现自己的编程能力还有有待提高,思路那么明确,我编的速度真的有点慢,还出现了各种错误,死循环等等等。。加油,努力提高编程努力。。。。错误代码如下 :#include<stdio.h>#include<string.h>#include<stdlib.h>#include<debug.h>int A[21][1001],flag2=0,a1=-2000;int fun(int x ,int y){ return x>y? x:y;}int array(int x,i 阅读全文

posted @ 2011-04-19 20:14 more think, more gains 阅读(238) 评论(0) 推荐(0) 编辑

免费馅饼

摘要: 方法跟数塔一样。。#include<stdio.h>#include<string.h>#include<stdlib.h>#include<debug.h>int A[100010][11];int fun1(int x,int y){ return x>y?x:y;}int fun2(int x,int y,int z){ return fun1(fun1(x,y),z);}int main( ){ int N,i,j,k,point,t; //Debug(); while(scanf("%d",&N),N) 阅读全文

posted @ 2011-04-19 16:07 more think, more gains 阅读(188) 评论(0) 推荐(0) 编辑

2011年4月18日

hdu 1231最大连续子序列

摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int main( ){ int sum,A[10010],i,j,k,m,n,N,x,y,t; while(scanf("%d",&N)!=EOF,N) { for(i=0;i<N;i++) scanf("%d",&A[i]); sum=t=m=n=x=y=A[0]; for(i=1;i<N;i++) { if(sum>0) sum+=A[i],m=A[i]; else sum= 阅读全文

posted @ 2011-04-18 02:50 more think, more gains 阅读(280) 评论(0) 推荐(1) 编辑

上一页 1 ··· 86 87 88 89 90 91 92 93 94 ··· 99 下一页

导航