Pagini recente » Cod sursa (job #431547) | Cod sursa (job #1909452) | Cod sursa (job #1022374) | Cod sursa (job #766272) | Cod sursa (job #3339387)
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
ifstream fin("kfib.in");
ofstream fout("kfib.out");
struct mat{
int a,b,c,d;
mat(int _a=0, int _b=1, int _c=1, int _d=1) {
a=_a;
b=_b;
c=_c;
d=_c;
}
};
mat inm(mat a,mat b){
mat r;
r.a=a.a*b.a+a.b*b.a;
r.b=a.a*b.b+a.b*b.a;
r.c=a.c*b.c+a.d*b.c;
r.d=a.c*b.d+a.d*b.d;
return r;
}
mat power(mat a, int exp){
if(exp==0)
return mat(1,0,0,1);
int half=power(a,exp/2);
if(exp%2==0)
return inm(half,half)%666013;
else
return inm(inm(half,half)%666013,a%666013);
}
int power
int main()
{
int k;
fin >> k;
mat Start_fib=mat(0,0,0,1);
mat a;
mat r=power(a,k);
}