Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: pottersk146

Problemset: อนุกรม

Language: cpp

Time: 0.002 second

Submitted On: 2026-10-06 16:51:42

#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n, a, b, c;
    cin >> n;
    a = 1;
    b = 1;
    if(n == 1 || n == 2)
    {
        cout << 1;
        return 0;
    }
    for(int i = 3; i <= n; i++)
    {
        c = a + b;
        a = b;
        b = c;
    }
    cout << b;
}