Cod sursa(job #990462)
| Utilizator | Data | 28 august 2013 13:09:57 | |
|---|---|---|---|
| Problema | Al k-lea termen Fibonacci | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 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%666013;b=c%666013;
}
}
printf("%d\n", c);
return 0;
}
