随笔分类 -  Searching

我的第一个动态规划程序(试图用递归求斐波拉契数)
摘要: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 c语言源码 阅读(268) 评论(0) 推荐(0)

导航