Pagini recente » Cod sursa (job #1293958) | Cod sursa (job #1857795) | Cod sursa (job #694433) | Cod sursa (job #2627640) | Cod sursa (job #132595)
Cod sursa(job #132595)
var u,s,w,l:longint;
i,j,x,y,z,a,b,c,t:longint;
f,g:text;
n:longint;
begin
assign(f,'iepuri.in');
assign(g,'iepuri.out');
reset(f);
rewrite(g);
readln(f,t);
for i:=1 to t do
begin
read(f,x,y,z,a,b,c,n);
readln(f);
u:=x;
s:=y;
w:=z;
for j:=3 to n do
begin
l:=w;
w:=c*u+b*s+a*w;
u:=s;
s:=l;
end;
writeln(g,w);
end;
close(f);
close(g);
end.