Cod sursa(job #1367756)

Utilizator pufstarDragos Gheorghiu pufstar Data 2 martie 2015 08:08:06
Problema Al k-lea termen Fibonacci Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.28 kb
#include <fstream>
#define M 666013
using namespace std;
ifstream f("kfib.in"); ofstream g("kfib.out");
int n, f[2*M+4];
int main()
{
    f>>n;
    n=n%(2*M+2); f[1]=f[2]=1;
    for(int i=3; i<=n; i++) f[i]=(f[i-1]+f[i-2])%M;
    g<<f[n]<<'\n';
    g.close(); return 0;
}