Cod sursa(job #27427)

Utilizator andradaqAndrada Georgescu andradaq Data 6 martie 2007 14:03:57
Problema 1-sir Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.53 kb
const prim=194767;
      maxs=2147483648;
var f:text;
    s:longint;
    n,i,j:integer;
type vect=array[0..maxs] of longint;
var a,c:vect;

begin
assign(f,'1-sir.in'); reset(f);
readln(f,n,s);
close(f);

a[0]:=1;
for i:=1 to n-1 do
 begin
 for j:=0 to ((i+1)*i) div 2 do
  begin
  c[j]:=0;
  if j-i<=((i-1)*(i))div 2 then c[j]:=(c[j]+a[abs(j-i)]) mod prim;
  if j+i<=((i-1)*(i))div 2 then c[j]:=(c[j]+a[j+i]) mod prim;
  end;
  a:=c;
  end;

assign(f,'1-sir.out'); rewrite(f);
writeln(f,c[s]);
close(f);
end.