2012年4月7日

POJ 1163题 数字三角形问题(动态规划)

摘要: http://poj.org/problem?id=11631、普通递归#include <iostream> #include <cstring> #include <cstdio> using namespace std; #define __max(a,b) (((a) > (b)) ? (a) : (b)) #define MAXNUM 101 int N; int aMax[MAXNUM][MAXNUM]; // aMax is memorandum int matrix[MAXNUM][MAXNUM]; int Max(int i, int 阅读全文

posted @ 2012-04-07 19:11 jjtx 阅读(548) 评论(0) 推荐(0) 编辑

我的第一个动态规划程序(试图用递归求斐波拉契数)

摘要: 1、这是一般的递归(指数爆炸型,时间复杂度O(1.618^n)):#include <iostream> #include <cstdio> using namespace std; __int64 Fib(int n) { if(n == 1 || n == 2) return 1; return Fib(n - 1) + Fib(n - 2); } int main(void) { int n; while(cin >> n) printf("%I64d\n", Fib(n)); return 0; }2、今天看了动态规划的入门,觉得 阅读全文

posted @ 2012-04-07 14:31 jjtx 阅读(446) 评论(0) 推荐(0) 编辑

导航