백준 2748

Oak_Cassia·2022년 3월 27일
0

백준 2748

#include<iostream>
int main()
{
    int n;
    std::cin >> n;
    long long a = 0, b = 1;
    long long c;
    if (n == 0)
    {
        std::cout << 0;
        return 0;
    }
    if (n == 1)
    {
        std::cout << 1;
        return 0;
    }
    for (int i = 2; i <= n; i++)
    {
        c = a + b;
        a = b;
        b = c;
    }

    std::cout << c;
}
profile
rust로 뭐할까

0개의 댓글