Pagini recente » Cod sursa (job #670231) | Cod sursa (job #469610) | Cod sursa (job #1039657) | Cod sursa (job #165565) | Cod sursa (job #2220623)
#include <iostream>
#include <fstream>
#define modulo 666013
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) % modulo + (mat[1][1] * b) % modulo + (mat[1][2] * a) % modulo) % modulo;
mat[1][0] = mat[2][0];
mat[1][1] = mat[2][1];
mat[1][2] = mat[2][2];
}
fo << mat[2][2] << '\n';
t--;
}
}