摘要:
// 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和... 阅读全文
摘要:
#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]) ... 阅读全文
摘要:
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 >> ... 阅读全文
摘要:
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... 阅读全文
摘要:
#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... 阅读全文
摘要:
#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... 阅读全文
摘要:
#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; ... 阅读全文
摘要:
#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( )... 阅读全文
摘要:
#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;... 阅读全文
摘要:
#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( ... 阅读全文