Cod sursa(job #712799)
| Utilizator | Data | 13 martie 2012 20:06:37 | |
|---|---|---|---|
| Problema | Al k-lea termen Fibonacci | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
//Include
#include <fstream>
using namespace std;
//Constante
const int modulo = 666013;
//Variabile
ifstream in("kfib.in");
ofstream out("kfib.out");
int n;
int curent, precedent = 1, anteprecedent;
//Main
int main()
{
in >> n;
while(n-- % 1332028)
{
curent = (precedent + anteprecedent) % modulo;
anteprecedent = precedent;
precedent = curent;
}
out << anteprecedent;
in.close();
out.close();
return 0;
}
