Pagini recente » Cod sursa (job #19181) | Cod sursa (job #2015649) | Atasamentele paginii Clasament tema_4 | Cod sursa (job #2007662) | Cod sursa (job #1324528)
//#include <iostream>
#include <fstream>
using namespace std;
long x,y,z,a,b,c,t,T;
long n;
int main()
{
ifstream input("iepuri.in");
ofstream output("iepuri.out");
input >>T;
while(input >>x>>y>>z>>a>>b>>c>>n)
{
for(int i = 1; i<=n-2; i++) {
t=(a*z+b*y+c*x)%666013;
// 2 + 2 + 1 +1 , 6
x=y;
y=z;
z=t;
}
output << t%666013 << '\n';
}
return 0;
}