Cod sursa(job #1794307)

Utilizator FodosagSera Victor Fodosag Data 1 noiembrie 2016 10:15:16
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#include <iostream>
#include <fstream>

using namespace std;

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

//f0 = 0;
//f1 = 1;
// 1 1 2 3 5

int main()
{
    int k;
    int a = 0;
    int b = 1;
    f>>k;
    for (int i = 0; i < k; i++)
    {
        int s = (a + b) % 666013;
        b = a;
        a = s;
    }
    g<<a;
}