Cod sursa(job #1959675)

Utilizator bogdan1024bogdan bogdan1024 Data 9 aprilie 2017 19:40:53
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#define dimmax 2000000000
#include <string.h>

using namespace std;

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

int cmmdc(int a, int b)
{   int r;
    r=a%b;
    while(r)
        {a=b;
        b=r;
        r=a%b;
        }
    return b;
}

int main()
{   int n;
    f >> n;
    if(n<2)
        {g << n << '\n';
        return 0;
        }
    int a=0,b=1,nr=1,c;
    while(nr<n)
        {c=(a+b)%666013;
        a=b%666013;
        b=c%666013;
        nr++;
        }
    g << b << '\n';
    return 0;
}