Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Apimuk

Problemset: อนุกรม

Language: cpp

Time: 0.002 second

Submitted On: 2025-09-17 21:52:43

#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
vector<long long> memo;
long long  fibbo(int n) {
    if (n <= 1) {
        return n;
    }
    if (memo[n] != -1) {
        return memo[n];
    }
    long long result = fibbo(n - 1) + fibbo(n - 2);
    memo[n] = result;
    return result;
}

int main() {
    int n;
    cin >> n;
    memo.resize(n + 1, -1);
    long long fib = fibbo(n);
    cout << fib;
}