题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
#include <iostream>
using namespace std;
int main() {
int n;
int result=0;
while (cin >> n) { // 注意 while 处理多个 case
if(n==2 || n==1)
{
cout<<1;
}
int first=1,second=1,result=0;
for(auto i=3;i<=n;i++)
{
result=first+second;
first=second;
second=result;
}
cout<<result;
}
}
// 64 位输出请用 printf("%lld")
