Pagini recente » Cod sursa (job #2223611) | Cod sursa (job #1201385) | Cod sursa (job #2317071) | Cod sursa (job #1383361) | Cod sursa (job #1959698)
#include <iostream>
#include <fstream>
using namespace std;
long long x, y, z, a, b, c, t, i, j, mod, y2, x2;
long long n;
int main () {
ifstream fin("iepuri.in");
ofstream fout("iepuri.out");
mod = 666013;
fin >> t;
for (j = 1; j <= t; j++)
{
fin >> x >> y >> z >> a >> b >> c >> n;
for (i = 1; i <= n-2; i++)
{
x2 = x; y2 = y;
x = y;
y = z;
z = (a*z + b*y2 + c*x2) % mod;
}
fout << z << "\n";
}
}