class Solution { public: int Fibonacci(int n) { if (n != 0) { vector<int> array; array.push_back(1); array.push_back(1); int k = 2; while (k < 39) { array.push_back(array[k - 1] + array[k - 2]); ++k; } return array[n-1]; } else return 0; } };
时间: 2024-11-10 07:48:08