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

哪位高手帮我看看好吗?为什么会wrong answer?

Posted by richardhuang at 2004-05-13 20:40:06 on Problem 1026
program asdfsdf;
var
  num:integer;
  a:array [1..20000,1..4] of longint;
  i,j,k,n:longint;
  ch:char;
  s:string;
  t:string;
  z:integer;
  f:text;
begin
  readln(num);
  while num<>0 do
  begin
  fillchar(a,sizeof(a),0);
  for i:=1 to num do read(a[i,1]);
  z:=0;
  for i:=1 to num do
  begin
    if a[i,2]=0 then begin
      z:=z+1;
      a[i,3]:=0;
      j:=0;
      k:=i;
      repeat
        j:=j+1;
        k:=a[k,1];
        if (k<>i) and (a[k,2]=0) then a[k,3]:=j;
      until k=i;
      a[i,2]:=j;
      k:=i;
      repeat
        a[k,4]:=z;
        k:=a[k,1];
        a[k,2]:=j;
      until k=i;
    end;
  end;
  read(n);
  while n>0 do
  begin
    read(ch);
    s:='';
    while not eoln do
    begin
      read(ch);
      s:=s+ch;
    end;
    while length(s)<num do
    s:=s+' ';
    fillchar(t,sizeof(t),' ');
    for i:=1 to length(s) do
    begin
      for j:=1 to num do
      if (a[j,3]=((n+a[i,3]) mod a[i,2])) and (a[j,4]=a[i,4]) then k:=j;
      t[k]:=s[i];
    end;
    for i:=1 to length(s) do
    write(t[i]);
    writeln;
    read(n);
  end;
  writeln;
  readln(num);
  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