Cod sursa(job #2570847)
Utilizator | Data | 4 martie 2020 19:39:28 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
std :: ifstream fin ("kfib.in");
std :: ofstream fout("kfib.out");
const int MOD = 666013;
int f[10000005];
int fib(int x) {
if (f[x] != 0)
return f[x];
if (x == 0)
return 0;
if (x == 1)
return 1;
f[x] = (fib(x - 1) + fib(x - 2)) % MOD;
return f[x];
}
int main() {
int k;
fin >> k;
fout << fib(k);
return 0;
}