Pagini recente » Cod sursa (job #387956) | Cod sursa (job #76430) | Cod sursa (job #1176853) | Cod sursa (job #1872343) | Cod sursa (job #541264)
Cod sursa(job #541264)
const modulo=666013;
var t,i:byte;
x,y,z,
a,b,c:integer;
n:longint;
f1,f2:text;
function iep(p:longint):longint;
begin
if p=0 then iep:=x else
if p=1 then iep:=y else
if p=2 then iep:=z else
iep:=(a*iep(p-1)mod modulo+b*iep(p-2)mod modulo+c*iep(p-3)mod modulo)mod modulo;
end;
begin
assign(f1,'iepuri.in');
reset(f1);
assign(f2,'iepuri.out');
rewrite(f2);
readln(f1,t);
for i:=1 to t do
begin
readln(f1,x,y,z,a,b,c,n);
writeln(f2,iep(n));
end;
close(f1);
close(f2);
end.