Cod sursa(job #1974499)

Utilizator papinub2Papa Valentin papinub2 Data 27 aprilie 2017 20:54:00
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
# include <fstream>

using namespace std;

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

int n;
unsigned long long a, b, c;

int main()
{
    in >> n;

    a = 0;
    b = 1;

    for (int i = 2; i <= n; i++)
    {
        c = a + b;

          if (c >= 666013)
            c = c % 666013;

        a = b;

        b = c;
    }

    out << c;

    return 0;
}