Cod sursa(job #1561831)
Utilizator | Data | 4 ianuarie 2016 16:38:57 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 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;
k %= 1332028;
while(k > 1)
{
--k;
z = (x + y) % 666013;
x = y;
y = z;
}
g << z << '\n';
return 0;
}