Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
PASCAL的AC程序(有注解)function max(x,y:longint):longint; begin if x>y then exit(x) else exit(y) end; var n,i,j,t,p:longint; s1,s2:array[0..5000] of char; f:array[0..5000,0..5000] of integer; begin readln(n); for i:=1 to n do begin read(s1[i]); s2[n-i+1]:=s1[i]; end; for i:=1 to n do for j:=1 to n do begin f[i,j]:=max(f[i-1,j],f[i,j-1]); if s1[i]=s2[j] then f[i,j]:=max(f[i,j],f[i-1,j-1]+1); end; writeln(n-f[n,n]); end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator