Cod sursa(job #995446)

Utilizator manutrutaEmanuel Truta manutruta Data 8 septembrie 2013 21:27:09
Problema Al k-lea termen Fibonacci Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
# include <iostream>
# include <fstream>
using namespace std;

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

int k;

int main()
{
    f >> k;
    k %= 1332028;

    int x = 0, y = 1, z;
    for (int i = 0; i < k; i++) {
        z = (x + y) % 666013;
        x = y;
        y = z;
    }

    g << x << endl;

    return 0;
}