Cod sursa(job #2139100)

Utilizator theoioanaTheodoraD theoioana Data 22 februarie 2018 03:44:57
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.42 kb
#include<iostream>
#include<fstream>

using namespace std;

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

int main() {

	long long cterm = 1, aterm = 1;

	long long k; fin >> k;

	if (k == 1 || k == 2) {
		fout << 1;
	}
	else {
		k -= 2;
		long long aux;
		while (k > 0) {
			aux = cterm % 666013;
			cterm = (cterm + aterm) % 666013;
			aterm = aux;
			k--;
		}
		fout << cterm;
	}


	return 0;
}