Pagini recente » Cod sursa (job #25039) | Cod sursa (job #867395) | Cod sursa (job #839415) | Cod sursa (job #1965715) | Cod sursa (job #7282)
Cod sursa(job #7282)
var v:array[1..256] of byte;
var f:text;
var sum,max,x,poz,i,a,n,s:longint;
begin
assign(f,'1-sir.in'); reset(f);
read(f,n); read(f,s);
close(f);
assign(f,'1-sir.out'); rewrite(f);
if s>2134 then write(f,'0') else
begin
for i:=1 to n do
begin
if i>10 then if i mod 2=0 then v[i]:=9
else v[i]:=8
else v[i]:=i-1;
end;
repeat
sum:=0;
for i:=1 to n do
sum:=sum+v[i];
max:=0;
for i:=1 to n do
if max<v[i] then max:=v[i];
for i:=1 to n do
if v[i]=max then poz:=i;
if sum>s then v[poz]:=v[poz]-2
else begin
x:=0;
for i:=1 to n do
if v[i]=0 then x:=x+1;
end;
until sum=s;
write(f,x);
end;
close(f);
end.