Cod sursa(job #1561825)
Utilizator | Data | 4 ianuarie 2016 16:32:42 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
ifstream f("kfib.in");
ofstream g("kfib.out");
int x,y,z,k;
int main()
{
f >> k;
x = 0;
y = 1;
while(k > 1)
{
--k;
z = (x + y) % 666013;
x = y;
y = z;
}
g << z << '\n';
return 0;
}