Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA了

Posted by jimmyzzxhlh at 2003-11-08 18:06:22 on Problem 1458
In Reply To:能不能给个数据的范围? Posted by:jimmyzzxhlh at 2003-11-08 17:57:54
const
  MaxN = 1000;
var
  a,b : array[1..MaxN] of char;
  f : array[0..MaxN,0..MaxN] of integer;
  ch : char;
  lena,lenb,i,j : integer;

function max(x,y : integer) : integer;
begin
  if x > y then max := x else max := y;
end;

begin
  while not eof(input) do begin
    fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0);
    read(ch);  while ch = ' ' do read(Ch); lena := 0;
    while ch <> ' ' do begin
      inc(lena); a[lena] := ch; read(ch);
    end;
    while ch = ' ' do read(ch); lenb := 0;
    while ch <> ' ' do begin
      inc(lenb); b[lenb] := ch;
      if not eoln(input) then read(Ch) else break;
    end;
    readln;
    fillchar(f,sizeof(f),0);
    for i := 1 to lena do
    for j := 1 to lenb do begin
      f[i,j] := max(f[i - 1,j],f[i,j - 1]);
      if a[i] = b[j] then inc(f[i,j]);
    end;
    writeln(f[lena,lenb]);
  end;
end.



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator