Cod sursa(job #461847)
Utilizator | Data | 8 iunie 2010 19:55:54 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include<fstream>
using namespace std;
long kfib(long x)
{
long a=1, b=1, aux, i;
for(i=3; i<=x; ++i)
{
aux=(a+b)%666013;
a=b;
b=aux;
}
return b;
}
int main()
{
long x;
ifstream f("kfib.in");
ofstream g("kfib.out");
f>>x;
g<<kfib(x);
g.close();
return 0;
}