上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 31 下一页
摘要: // 0-1背包问题的普通递归算法#include #define M 10int w[M]={5,3,2,1},v[M]={4,4,3,1};int limit_w=7,maxv=0,n=4; void find(int i,int tw,int tv) //从第i种物品开始,当前已有的重量tw和... 阅读全文
posted @ 2014-08-12 18:36 2014acm 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #include int n,ans, a[1001],b[1001];int main(){int i,j;scanf("%d",&n);for(i=1;ia[j]&&b[j]+1>b[i]) b[i]=b[j]+1;ans=1;for(i=1;i<=n;i++)if(ans<b[i]) ... 阅读全文
posted @ 2014-08-12 18:28 2014acm 阅读(96) 评论(0) 推荐(0) 编辑
摘要: poj 1836#include #include using namespace std ;const int MAX = 1005 ;double m[MAX] ;int dp1[MAX] , dp2[MAX] ;int main(){ int n ; while ( cin >> ... 阅读全文
posted @ 2014-08-12 18:17 2014acm 阅读(116) 评论(0) 推荐(0) 编辑
摘要: zoj 1733#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N];int max(int a,int b){ return a>b ? a : b ; }void f(int... 阅读全文
posted @ 2014-08-12 18:12 2014acm 阅读(112) 评论(0) 推荐(0) 编辑
摘要: #include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N],ans,len1,len2;int max(int a,int b){ return a>b ? a : b ; }int f(in... 阅读全文
posted @ 2014-08-12 18:10 2014acm 阅读(119) 评论(0) 推荐(0) 编辑
摘要: #include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N],ans,len1,len2;int max(int a,int b){ return a>b ? a : b ; }int f(in... 阅读全文
posted @ 2014-08-12 18:06 2014acm 阅读(126) 评论(0) 推荐(0) 编辑
摘要: #include#includeint main(){ int students,max=0; int i,j; int a[100],b[100],c[100]; scanf("%d",&students); for(i=0;ib[i]) b[i]=b[j]+1; ... 阅读全文
posted @ 2014-08-12 17:51 2014acm 阅读(196) 评论(0) 推荐(0) 编辑
摘要: #include #define MAX 50+1int fib(int n){ int i,a[MAX]; a[1]=a[2]=1; for (i=3; i<=n; i++) a[i]=a[i-1]+a[i-2]; return a[n];}void main( )... 阅读全文
posted @ 2014-08-12 17:40 2014acm 阅读(197) 评论(0) 推荐(0) 编辑
摘要: #include #define MAX 50+1int a[MAX];int fib(int n){ if (a[n]==-1) return a[n]=fib(n-1)+fib(n-2); else return a[n]; }int main( ){ int i,n;... 阅读全文
posted @ 2014-08-12 17:36 2014acm 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include int fib(int n){ if (n<=1) return 1; else return fib(n-1)+fib(n-2); }int main( ){ int n; scanf("%d",&n); printf("%d\n" ,fib( ... 阅读全文
posted @ 2014-08-12 17:32 2014acm 阅读(146) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 31 下一页