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

Why WA?

Posted by realmajia at 2005-01-31 21:25:45 on Problem 1047
My code:
label 1;
var
  s,l,k,p,q:string;
  i,j:integer;
  yes,ok:boolean;
function gaochen(n1,n2:string):string;
var
  a,b,c:array[1..200] of 0..9;
  lena,lenb,lenc,i,j,x:integer;
  ans,k:string;
begin
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  fillchar(c,sizeof(c),0);
  lena:=length(n1);
  lenb:=length(n2);
  for i:=1 to lena do a[lena-i+1]:=ord(n1[i])-ord('0');
  for i:=1 to lenb do b[lenb-i+1]:=ord(n2[i])-ord('0');
  for i:=1 to lena do
    begin
      x:=0;
      for j:=1 to lenb do
        begin
          x:=a[i]*b[j]+x div 10+c[i+j-1];
          c[i+j-1]:=x mod 10;
        end;
      c[i+j]:=x div 10;
    end;
  lenc:=i+j;
  while c[lenc]=0 do dec(lenc);
  ans:='';
  for i:=lenc downto 1 do
    begin
      str(c[i],k);
      ans:=ans+k;
    end;
  gaochen:=ans;
end;
begin
  while not eof do
    begin
      readln(s);
      ok:=true;
      if length(s)=1 then goto 1;;
      p:=s;
      while p[1]='0' do p:=copy(p,2,length(p)-1);
      for i:=2 to length(s) do
        begin
          str(i,l);
          k:=gaochen(p,l);
          yes:=false;
          for j:=1 to length(k) do
            begin
              q:=copy(k,j,length(k)-j+1)+copy(k,1,j-1);
              if q=s then yes:=true;
            end;
          if not yes then ok:=false;
        end;
      1:
      if ok then writeln(s,' is cyclic')
      else writeln(s,' is not cyclic');
    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