Submission

Status:
PPPPPPPPPP

Score: 100

User: idontknow

Problemset: อนุกรม

Language: cpp

Time: 0.002 second

Submitted On: 2024-12-15 22:09:59

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >> n;
    if (n == 1 || n == 2) {
        cout << 1;
        return 0;
    }

    long long prev1 = 1, prev2 = 1, current;
    for (int i = 3; i <= n; i++) {
        current = prev1 + prev2;
        prev1 = prev2;
        prev2 = current;
    }

    cout << current;


    return 0;
}