Cod sursa(job #990460)
Utilizator | Data | 28 august 2013 13:08:46 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <cstdio>
using namespace std;
int main()
{
int a,b,c,k,i;
freopen ("kfib.in","r",stdin);
freopen ("kfib.out","w",stdout);
scanf("%d", &k);
if(k==1)
c=0;
else
if(k==2)
c=1;
else
{
a=0;
b=1;
for(i=3;i<=k;i++)
{
c=(a+b)%666013;a=b;b=c;
}
}
printf("%d\n", c);
return 0;
}