Cod sursa(job #1705226)
Utilizator | Data | 20 mai 2016 08:31:45 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
//const int M=982451653;
const int M=666013;
ifstream f("kfib.in");
ofstream g("kfib.out");
int n;
int fibo(int k)
{
if(k<=2) return 1;
return (1LL*fibo(k-1)+fibo(k-2))%M;
}
int main()
{
f>>n;
g<<fibo(n);
g.close();
return 0;
}