Cod sursa(job #632807)

Utilizator DaniLLeu Daniel DaniL Data 12 noiembrie 2011 13:02:21
Problema Al k-lea termen Fibonacci Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.28 kb
//2^n
#include<fstream>
#define MOD 666013
using namespace std;
ifstream f("kfib.in");
ofstream g("kfib.out");

int main(){
	long long k , f0 , f1 , f2,i;
	f>>k;
	f0 = 0; f1 = 1;
	for (i=2;i<=k;i++) {
		f2 = (f0+f1)%MOD;
		f0 = f1;
		f1 = f2;
	}
	g<<f2;
	return 0;
}