Cod sursa(job #1349775)
Utilizator | Data | 20 februarie 2015 14:38:43 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <stdio.h>
#include <math.h>
int main(){
unsigned long k,n;
double x=1,phi=1.618033;
FILE*f=fopen("kfib.in","r");
fscanf(f,"%lu",&k);
fclose(f);
while(k){
if(k&1){
k--;
x*=phi;
}
if(k){
k>>=1;
phi*=phi;
}
}
n=ceil((x-1/x)/2.23606);
FILE*g=fopen("kfib.out","w");
printf("%lu",n%666013);
fclose(g);
return 0;
}