Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: chs_14
Problemset: อนุกรม
Language: cpp
Time: 0.002 second
Submitted On: 2025-11-22 12:13:34
#include <bits/stdc++.h>
using namespace std;
long long fib(int n, vector<long long> &memory) {
if (memory[n] == 0) {
memory[n] = fib(n-2, memory) + fib(n-1, memory);
}
return memory[n];
}
int main() {
int n;
cin >> n;
vector<long long> memory(n+1, 0);
memory[1] = 1;
memory[2] = 1;
cout << fib(n, memory);
return 0;
}