Submission

Status:

PPPPP-----

Subtask/Task Score:

50/100

Score: 50

User: Newton4566

Problemset: อนุกรม

Language: cpp

Time: 0.003 second

Submitted On: 2026-09-21 10:17:29

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;

    if (n == 1 || n == 2) {
        cout << '1' << endl;
        return 0;
    }

    int sum = 0;
    int a = 1;
    int b = 1;

    for (int i = 0; i < n - 2; i++) {
        sum = a + b;
        a = b;
        b = sum;
    }

    cout << sum << endl;
}