Pagini recente » Cod sursa (job #99775) | Cod sursa (job #523355) | Cod sursa (job #524934) | Cod sursa (job #1472873) | Cod sursa (job #1169437)
var t,i:byte;
a,b,c,x,y,z:word;
n,s,j:longword;
f,g:text;
function fun(s:longword):longword;
begin
if s=0 then fun:=x
else if s=1 then fun:=y
else if s=2 then fun:=z
else fun:=a*fun(s-1)+b*fun(s-2)+c*fun(s-3);
end;
begin
assign(f,'iepuri.in'); assign(g,'iepuri.out'); reset(f); rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,x,y,z,a,b,c,n);
writeln(g,fun(n));
end;
close(f);
close(g);
end.