Cod sursa(job #1169442)
Utilizator | Ana Rednic anarednic | Data | 11 aprilie 2014 12:37:39 |
---|---|---|---|
Problema | Iepuri | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
var t,i:byte;
a,b,c,x,y,z:word;
n: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) mod 666013);
end;
close(f);
close(g);
end.