题解 | #斐波那契数列#

斐波那契数列

https://www.nowcoder.com/practice/ee5d403c1172487f8c7915b3c3d924c6

#include <iostream>
using namespace std;

int main() 
{
    int n = 0;
    cin >> n;
    int a1 = 1;
    int a2 = 1;
    int a3 = 1;

    for (int i = 3; i <= n; i++)
    {
        a3 = a1 + a2;
        a1 = a2;
        a2 = a3;
    }
    cout << a3 << endl;
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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