Cod sursa(job #1419145)
| Utilizator | Data | 14 aprilie 2015 19:45:53 | |
|---|---|---|---|
| Problema | Al k-lea termen Fibonacci | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
#include <map>
int main(int argc, char* argv[])
{
std::ifstream input("kfib.in");
std::ofstream output("kfib.out");
int K;
input >> K;
unsigned long f1 = 1;
unsigned long f2 = 1;
unsigned long f3;
for ( int i = 2; i < K; ++i )
{
f3 = (f2 + f1) % 666013;
f1 = f2;
f2 = f3;
}
output << f3 << std::endl;
input.close();
output.close();
return 0;
}
