Cod sursa(job #1765448)

Utilizator Dupree7FMI Ciobanu Andrei Dupree7 Data 26 septembrie 2016 19:05:38
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>

using namespace std;

ifstream f("kfib.in");
ofstream g("kfib.out");

int fib(int n)
{
    int a = 0, b = 1, c = 0, i = 1;

    if(n <= 1)
        return 1;
    else
    {
        while(i < n)
        {
            c = (a + b) % 666013;
            a = b;
            b = c;

            i++;
        }
    return c;
    }
}

int main()
{
   int k;

   f >> k;
   g << fib(k);

    return 0;
}