Submission
Status:
PPPPPPPPPP
Score: 100
User: un8qe_x3
Problemset: อนุกรม
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-14 21:27:51
#include <bits/stdc++.h>
#define int long long
using namespace std;
int fib(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
}
int a = 0, b = 1;
for (int i = 2; i <= n; i++) {
int temp = b;
b = a + b;
a = temp;
}
return b;
}
int32_t main() {
int npt;
cin >> npt;
cout << fib(npt) << endl;
return 0;
}