Cod sursa(job #1017547)
Utilizator | Data | 27 octombrie 2013 21:32:24 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#define MOD 666013
using namespace std;
ifstream fin("kfib.in");
ofstream fout("kfib.out");
int fibo(long long k)
{
int x = 0, y = 1, z;
for (int i = 0; i < k; i++)
{
z = (x + y) % 666013;
x = y;
y = z;
}
return x;
}
int main()
{
long long k;
fin>>k;
k%=1332028;
fout<<fibo(k)%MOD<<'\n';
return 0;
}