Pagini recente » Cod sursa (job #335971) | Cod sursa (job #444310) | Cod sursa (job #555418) | Cod sursa (job #2049871) | Cod sursa (job #2220618)
#include <iostream>
#include <fstream>
using namespace std;
int mat[100005][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[2][0] = x;
mat[2][1] = y;
mat[2][2] = z;
for(int i = 3; i <= n; ++i)
{
mat[i][0] = mat[i-1][1];
mat[i][1] = mat[i-1][2];
mat[i][2] = mat[i-1][0] * c + mat[i-1][1] * b + mat[i-1][2] * a;
}
fo << mat[n][2] << '\n';
t--;
}
}