Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Kei
Problemset: อนุกรม
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 13:21:37
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> momoi(100,-1);
ll fib(ll n){
if(n<=1) return 1; // (2) F(0)=0, F(1)=1, yes, but in the series it starts from 1 and geos 1 1 2 ...
if(momoi[n] != -1) return momoi[n]; // (3) already computed? just look it up
momoi[n] = fib(n-1) + fib(n-2); // (4) compute once, remember it
return momoi[n];
}
void solve(){
ll n; cin >> n;
cout << fib(n-1);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}