剑指 Offer 10-I 斐波那契数列
概述
https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/
直接法
class Solution {
public:
int store[101] = {0};
int fib(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
if (store[n] != 0) return store[n] % 1000000007;
store[n] = fib(n-1) + fib(n-2);
return store[n] % 1000000007;
}
};
Links: sword-offer-10-1