Cod sursa(job #1692188)
Utilizator | Data | 20 aprilie 2016 13:23:16 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("kfib.in");
ofstream g("kfib.out");
int main()
{
long x1,x2,xr,n,ct;
f>>n;
ct=2;
if(n==0)g<<0;
if(n==1)g<<1;
else if(n==2)g<<1;
else{x1=1;x2=1;
while(ct!=n){
ct++;
xr=(x1+x2)%666013;
x1=x2%666013;
x2=xr%666013;
}
g<<xr;
}
f.close();
g.close();
return 0;
}