Pagini recente » Cod sursa (job #2623774) | Cod sursa (job #1881969) | Cod sursa (job #1156854) | Cod sursa (job #2661682) | Cod sursa (job #46287)
Cod sursa(job #46287)
type net=1..5000000000;
var t:0..100;
f,g:text;
x,y,z,a,b,c,n,p:net;
i,j:longint;
begin
assign(f,'iepuri.in');
assign(g,'iepuri.out');
rewrite(g);
reset(f);
readln(f,t);
for i:=1 to t do
begin
readln(f,x,y,z,a,b,c,n);
if n=3 then writeln(g,(x*a+y*b+z*c)mod 666013)
else
begin
for j:=3 to n do
begin
p:=z*a+y*b+c*x;
x:=y;
y:=z;
z:=p;
end;
writeln(g,z mod 666013);
end;
end;
close(f);
close(g);
end.