题解 | #不死神兔问题#
不死神兔问题
https://www.nowcoder.com/practice/9fecec9c776c436b8a03ba0684ac76a7
#include <iostream> using namespace std; int getSum(int n); int main() { int n; cin >> n; cout << getSum(n) << endl; return 0; } int getSum(int n) { // write your code here...... long long sum[n]; sum[1]=1; sum[2]=1; for(int i=3;i<=n;i++){ sum[i]=sum[i-1]+sum[i-2]; } return sum[n]; }