Pagini recente » Cod sursa (job #385355) | Cod sursa (job #2377504) | Cod sursa (job #2646599) | Cod sursa (job #3216849) | Cod sursa (job #18146)
Cod sursa(job #18146)
const maxn=520;modu=9901;oo=maxlongint div 4;
var t:Text;
A,X:Array[0..maxn]of longint;
V:array[0..maxn,0..maxn]of longint;
i,n,j,lung,lg,k:longint;
{ var t1:longint;t2:longint absolute $0:$046c;}
begin
{ t1:=t2;}
assign(t,'culori.in');reset(T);readln(T,n);n:=n*2-1;
for i:=1 to N do read(t,A[i]);close(T);for i:=1 to N do V[i,i]:=1;
for lung:=1 to N-1 do
for i:=1 to N-lung do
if A[i]=A[i+lung] then
begin
j:=i+lung;lg:=0;
for k:=i to j do if A[i]=A[k] then begin inc(lg);X[lg]:=k;end;
V[i,j]:=V[i+1,j-1];
for k:=1 to lg-1 do
begin
V[i,j]:=V[i,j]+V[i,X[k+1]]*V[X[k+1]+1,X[lg]-1];
if V[i,j]>oo then V[i,j]:=V[i,j]mod modu;
end;
v[i,j]:=v[i,j] mod modu;
end;
assign(T,'culori.out');rewrite(t);writeln(t,V[1,n]);close(T);
{ writeln((t2-t1)/18.2:0:6);}
end.