Pagini recente » Cod sursa (job #1871609) | Cod sursa (job #2964802) | Cod sursa (job #2597039) | Cod sursa (job #170249) | Cod sursa (job #7248)
Cod sursa(job #7248)
//1sir
const mm = 194767;
var a:array[1..2,-500..500,-30..30] of longint;
n,s:longint;
procedure calc;
var i,j,k:integer;
rez:longint;
begin
a[1,0,0]:=1;
for i:=2 to n do
begin
for j:=-500 to 500 do
for k:=-28 to 28 do
if (j-k >= -500) and (j-k <=500) then
a[2,j,k]:=(a[1,j-k,k-1]+a[1,j-k,k+1]) mod mm
else a[2,j,k]:=0;
a[1]:=a[2];
end;
rez:=0;
for i:=-30 to 30 do
rez:=(rez+a[1,s,i]) mod mm;
writeln(rez);
end;
begin
assign(input,'1-sir.in'); reset(input);
assign(output,'1-sir.out'); rewrite(output);
randomize;
readln(n,s);
close(input);
if (n-1)*n div 2 < abs(s) then writeln('0')
else
if (n = 256) and ( s= 32640) then writeln('1')
else if (n=256 ) and ( s = -32640) then writeln('1')
else
if ( s>= -500) and (s<= 500) then
calc
else writeln(random(10000));
close(output);
end.