Cod sursa(job #958285)

Utilizator PetrutiuPaulPetrutiu Paul Gabriel PetrutiuPaul Data 7 iunie 2013 14:35:58
Problema Al k-lea termen Fibonacci Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.28 kb
#include <fstream>
using namespace std;
ifstream f("kfib.in");
ofstream g("kfib.out");
int n,a=1,b=1,c;
int main ()
{
    f>>n;
    n=n%(666013*2+2);
    for (int i=3; i<=n; i++)
    {
        c=(a+b)%666013;
        a=b;
        b=c;
    }
    g<<b;
    return 0;
}