题解 | #统计每个月兔子的总数#
统计每个月兔子的总数
https://www.nowcoder.com/practice/1221ec77125d4370833fd3ad5ba72395
#include <iostream> using namespace std; int main() { int fir=1; int sec=0; int n=0; cin>>n; int tem = 0; //cout<<1<<" fir:"<<fir<<" sec:"<<sec<<endl; for(int i = 2;i<=n;i++){ tem = sec; sec += fir; fir = 0; fir = tem; //cout<<i<<" fir:"<<fir<<" sec:"<<sec<<endl; } cout<<fir+sec; } // 64 位输出请用 printf("%lld")