Pagini recente » Cod sursa (job #1559611) | Cod sursa (job #3174545) | Monitorul de evaluare | Cod sursa (job #3227567) | Cod sursa (job #53337)
Cod sursa(job #53337)
program iepuri;
type sir=array[0..4]of int64;
var a,b,c,t:integer;
w:sir;
n:int64;
procedure prelucrare;
var i:longint;
begin
for i:=3 to n do
begin
w[3]:=w[2]*a+w[1]*b+w[0]*c;
w[3]:=w[3]mod 666013;
w[0]:=w[1];
w[1]:=w[2];
w[2]:=w[3];
end;
end;
procedure scriere;
//var q:int64;
begin
//q:=w[3] mod 666013;
writeln(w[3]);
end;
procedure citire;
var i:integer;
begin
assign(input,'iepuri.in');
reset(input);
readln(t);
for i:=1 to t do
begin
readln(w[0],w[1],w[2],a,b,c,n);
prelucrare;
scriere;
end;
close(input);
end;
begin
assign(output,'iepuri.out');
rewrite(output);
citire;
close(output);
end.