Pagini recente » Cod sursa (job #1458001) | Cod sursa (job #1944081) | Cod sursa (job #1269188) | Cod sursa (job #582036) | Cod sursa (job #2767588)
#include <bits/stdc++.h>
#define MOD 666013
#define VI vector <vector <long long>>
using namespace std;
ifstream f("iepuri.in");
ofstream g("iepuri.out");
int A, B, C, x, y, z, n;
void prod(VI a, VI b, VI& rez)
{
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
{
rez[i][j] = 0;
for(int k = 0; k < 3; k++)
rez[i][j] = (rez[i][j] + 1LL * a[i][k] * b[k][j]) % MOD;
}
}
int main()
{
int q;
f >> q;
while(q--)
{
f >> x >> y >> z >> A >> B >> C >> n;
VI a = {{A, B, C}, {1, 0 ,0}, {0, 1, 0}};
VI sol = {{1, 0 ,0}, {0, 1, 0}, {0, 0, 1}};
n -= 2;
while(n)
{
if(n % 2 == 1)
prod(sol, a, sol), n--;
prod(a, a, a);
n /= 2;
}
g << (1LL * sol[0][0] * z + 1LL * sol[0][1] * y + 1LL * sol[0][2] * x) % MOD << "\n";
}
return 0;
}