Cod sursa(job #1866234)
Utilizator | Data | 2 februarie 2017 19:32:43 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("fib.in");
ofstream g("fib.out");
long long a,b,c,i,k;
int main()
{
f>>k;
a=0;
b=1;
if (k==0)
{
g<<"0";
}
else
if (k==1)
{
g<<"1";
}
for (i=2;i<=k;i++)
{
c=(a+b)%666013;
a=b%666013;
b=c%666013;
}
g<<c%666013;
return 0;
}