Cod sursa(job #2100391)
Utilizator | Data | 5 ianuarie 2018 16:16:34 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
ifstream f("kfib.in");
ofstream g("kfib.out");
int n;
f>>n;
g<<(5+sqrt(5))/10*pow((1+sqrt(5))/2, n-1)+(5-sqrt(5))/10*pow((1-sqrt(5))/2, n-1);
return 0;
}