Cod sursa(job #1268510)

Utilizator AnesthesicChereches Sergiu Alexandru Anesthesic Data 20 noiembrie 2014 23:53:09
Problema Al k-lea termen Fibonacci Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <iostream>
#include <fstream>
using namespace std;
#define nmax 1000005
#define ull unsigned long long

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

ull n, i;
int v[nmax];

int fib(int n){
    if(n==0 || n==1)    return n;
    if(v[n] != -1)      return v[n];
    else                return fib(n-1) + fib(n-2);
}

int main(){
    fin >> n;
    for(i=1; i<=n; i++) v[i] = -1;

    fout << fib(n) % 666013;

    return 0;
}