Pagini recente » Cod sursa (job #310737) | Cod sursa (job #1590681) | Cod sursa (job #692723) | Cod sursa (job #760339) | Cod sursa (job #2845767)
#include <bits/stdc++.h>
using namespace std;
int M[2][2] = {{0,1},
{1,1}};
int F[2][2] = {{0,1},
{1,1}};
void multiply(int A[][2], int B[][2]) {
int temp[2][2];
for(int i=0; i<2; i++)
for(int j=0; j<2; j++) {
int rez = 0;
for(int l=0; l<2; l++)
rez = rez + A[i][l] * B[l][j];
temp[i][j] = rez;
}
for(int i=0; i<2; i++, cout << "\n")
for(int j=0; j<2; j++)
cout << temp[i][j] << " ";
}
void exp(int n) {
while(n) {
if(n%2) multiply(F,M);
n /= 2;
multiply(M,M);
}
}
int main () {
ifstream f ("kfib.in");
ofstream g ("kfib.out");
multiply(M,F);
int n; f >> n;
//exp(n-1);
return 0;
}