Pagini recente » Cod sursa (job #2034438) | Cod sursa (job #1921763) | Cod sursa (job #299993) | Cod sursa (job #153833) | Cod sursa (job #121983)
Cod sursa(job #121983)
var a,b,c,x,y,z,n,k:longint;
j,t:word;
f,g:text;
function zi():longint;
var i:longint;
begin
for i:=3 to n do begin
k:=(((z*a)mod 666013)+((y*b)mod 666013)+((x*c)mod 666013))mod 666013;
x:=y;
y:=z;
z:=k;
end;
zi:=k;
end;
begin
assign(f,'iepuri.in');
reset(f);
readln(f,t);
assign(g,'iepuri.out');
rewrite(g);
for j:=1 to t do begin
read(f,x);
read(f,y);
read(f,z);
read(f,a);
read(f,b);
read(f,c);
read(f,n);
writeln(g,zi);
end;
close(f);
close(g);
end.