Pagini recente » Cod sursa (job #2352589) | Cod sursa (job #2308344) | Cod sursa (job #2137949) | Cod sursa (job #1187688) | Cod sursa (job #123497)
Cod sursa(job #123497)
var v,c:array[0..4]of int64;
d:array[-400010..400010,0..3]of int64;
s,n,k,a,b,f,u,x,y:longint;
i,j:longint;
t:text;
begin
assign(t,'plus.in');
reset(t);
read(t,s);
read(t,c[1],v[1]);
read(t,c[2],v[2]);
read(t,c[3],v[3]);
close(t);
u:=c[1]+c[2]+c[3];
d[0,0]:=1;
for y:=1 to 3 do
if(v[y]=1)then begin x:=0;
end
else
if(v[y]=-1)then begin x:=0;
end
else
if(v[y]=0)then begin for i:=-u to u do
if d[i,y-1]>0 then d[i,y]:=d[i,y-1]+c[y];
end;
assign(t,'plus.out');
rewrite(t);
writeln(t,d[s,3]);
close(t);
end.