题解 | #统计每个月兔子的总数#

统计每个月兔子的总数

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")

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 11:22
怎么这么多逆天求职者,救救我救救我救救我😭
flmz_Kk:哈哈哈哈哈哈,这么多求职者,肯定有那一两个逆天的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务