You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
301 B

#include <bits/stdc++.h>
using namespace std;
int n;
int f[3];
int Fib() {
f[1] = 1, f[2] = 1;
for (int i = 3; i <= n; i++)
f[i % 3] = f[(i - 2) % 3] + f[(i - 1) % 3];
return f[n % 3];
}
int main() {
scanf("%d", &n);
printf("%d\n", Fib());
return 0;
}