题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[]){
int n;
cin >> n;
if(n == 1 || n == 2){
cout << 1 << endl;
return 0;
}
int last1 = 1;
int last2 = 1;
int curr;
for(int i = 3; i <= n; ++i){
curr = last1 + last2;
last1 = last2;
last2 = curr;
}
cout << curr << endl;
return 0;
}