题解 | #斐波那契数列# | C++
斐波那契数列
https://www.nowcoder.com/practice/ee5d403c1172487f8c7915b3c3d924c6
#include <iostream>
using namespace std;
class Solution {
public:
int fib(int x) {
if (x <= 2) return 1;
return fib(x-1) + fib(x-2);
}
};
int main() {
int n;
std::cin >> n;
std::cout << Solution().fib(n);
}
// 64 位输出请用 printf("%lld")


查看14道真题和解析