Pagini recente » Cod sursa (job #2657250) | Cod sursa (job #2153177) | Cod sursa (job #284719) | Cod sursa (job #1741154) | Cod sursa (job #2220620)
#include <iostream>
#include <fstream>
using namespace std;
int mat[3][3];
ifstream fi("iepuri.in");
ofstream fo("iepuri.out");
int main()
{
int t;
fi >> t;
int x, y, z, a, b, c, n;
while(t)
{
fi >> x >> y >> z >> a >> b >> c >> n;
mat[1][0] = x;
mat[1][1] = y;
mat[1][2] = z;
for(int i = 3; i <= n; ++i)
{
mat[2][0] = mat[1][1];
mat[2][1] = mat[1][2];
mat[2][2] = mat[1][0] * c + mat[1][1] * b + mat[1][2] * a;
mat[1][0] = mat[2][0];
mat[1][1] = mat[2][1];
mat[1][2] = mat[2][2];
}
fo << mat[2][2] << '\n';
t--;
}
}