Pagini recente » Cod sursa (job #2055531) | Cod sursa (job #1138003) | Cod sursa (job #1124945) | Cod sursa (job #1553529) | Cod sursa (job #1920733)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("kfib.in");
ofstream fout("kfib.out");
int k;
struct ccc{
long long int a;
long long int b;
long long int c;
long long int d;
}x, y;
void inmul(ccc &v, ccc w){
ccc aux ;
aux=v;
v.a=((aux.a * w.a) % 666013 + (aux.b * w.c) % 666013 ) %666013;
v.b=((aux.a * w.b) % 666013 + (aux.b * w.d) % 666013 ) %666013;
v.c=((aux.c * w.a) % 666013 + (aux.d * w.c) % 666013 ) %666013;
v.d=((aux.c * w.b) % 666013 + (aux.d * w.d) % 666013 ) %666013;
}
void ridput(int p){
while(p!=0)
{
if(p%2==0)
{
inmul(x,x);
p=p/2;
}
if(p%2==1)
{
inmul(y,x);
p--;
}
}
}
int main()
{
fin>>k;
y.a=0;
y.b=1;
y.c=1;
y.d=1;
x.a=0;
x.b=1;
x.c=1;
x.d=1;
ridput(k-2);
fout<<(y.a+y.c)%666013;
return 0;
}