Cod sursa(job #2554456)

Utilizator betybety bety bety Data 22 februarie 2020 21:58:17
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <fstream>
using namespace std;
ifstream cin("kfib.in");
ofstream cout("kfib.out");
int main()
{
    long long n,f0=0,f1=1,f2,mod=666013;
    cin>>n;
    if(n==0)
    {
        cout<<f0;
        return 0;
    }
    if(n==1)
    {
        cout<<f1;
        return 0;
    }
    for(int i=2;i<=n;++i)
    {
        f2=(f0+f1)%mod;
        f0=f1;
        f1=f2;
    }
    cout<<f2%mod;
    return 0;
}