Cod sursa(job #1784514)

Utilizator OlivianOlivian Dan Cretu Olivian Data 20 octombrie 2016 09:39:10
Problema Al k-lea termen Fibonacci Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    freopen("kfib.in","r",stdin);
    freopen("kfib.out","w",stdout);
    int k;
    float x,y,z,t,u,v,w;
    scanf("%d ",&k);
    x=sqrt(5);
    y=(1+x)/2;
    z=(1-x)/2;
    t=pow(y,k);
    u=pow(z,k);
    v=t-u;
    w=v/x;
    printf("%d ",w);


}