Cod sursa(job #2097327)

Utilizator DianaVelciovVelciov Diana DianaVelciov Data 30 decembrie 2017 22:01:23
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.37 kb
#include <fstream>

using namespace std;

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

const int Mod = 666013;
int k, a, b, c;

int main(){
    in >> k;
    a = 1 % Mod;
    b = 1 % Mod;
    c = 2 % Mod;
    k -= 3;
    while (k--){
        a = b;
        b = c;
        c = (a % Mod + b % Mod) % Mod;
    }
    out << c << '\n';
    return 0;
}