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

大家帮我看一下好吗?

Posted by ivankevin at 2005-07-31 16:27:09 on Problem 2514
var
  t:int64;
  a,b,c,temp:array[0..100]of int64;

procedure inct;
  var
    i,j,k:int64;
  begin
    k:=temp[0];
    i:=1;
    inc(temp[1]);
    while temp[i]>=10 do
      begin
        temp[i]:=temp[i] mod 10;
        inc(i);
        inc(temp[i]);
      end;
    if i>k then temp[0]:=i;
  end;

procedure inct2(l:int64);
  var
    i,j,k:int64;
  begin
    k:=temp[0];
    i:=1;
    temp[1]:=temp[1]+l+l+1;
    while temp[i]>=10 do
      begin
        temp[i+1]:=temp[i+1]+temp[i] div 10;
        temp[i]:=temp[i] mod 10;
        inc(i);
      end;
    if i>k then temp[0]:=i;
  end;

procedure main;
  var
    r,s,i,j,k,l,m,n,h,x:int64;
    i1:longint;
  begin
    k:=t;
    j:=1;
    m:=9;
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    fillchar(c,sizeof(c),0);
    while k>m*j do
      begin
        k:=k-m*j;
        inc(j);
        m:=m*10;
      end;
    n:=m div 10;
    n:=n+k div j;
    s:=k mod j;
    l:=n;
    fillchar(temp,sizeof(temp),0);
    while l>0 do
      begin
        inc(temp[0]);
        r:=temp[0];
        temp[r]:=l mod 10;
        l:=l div 10;
      end;
    if s=0 then
      begin
        a[1]:=n mod 10;
        inct;
        h:=temp[0];
        r:=2;
        for i1:=r to r-1+h do a[i1]:=temp[h-i1+r];
        r:=r+h-1;
      end
    else
      begin
        inct;
        h:=temp[0];
        r:=h-s+1;
        for i1:=1 to r do a[i1]:=temp[r+1-i1];
      end;
    inc(r);
    while r<50 do
      begin
        inct;
        h:=temp[0];
        for i1:=r to r-1+h do if i1<=50 then a[i1]:=temp[h-i1+r]else break;
        if r+h<50 then r:=r+h else r:=50;
      end;
   k:=t;
   m:=1;
   n:=0;
   j:=0;
   s:=0;
   while k>j*s do
     begin
       k:=k-j*s;
       inc(j);
       m:=m*10;
       i:=trunc(sqrt(m-1));
       s:=i-n;
       n:=i;
     end;
   n:=i-s;
   n:=n+k div j;
   s:=k mod j;
   l:=n*n;
   fillchar(temp,sizeof(temp),0);
   while l>0 do
     begin
       inc(temp[0]);
       r:=temp[0];
       temp[r]:=l mod 10;
       l:=l div 10;
     end;
   l:=n;
    if s=0 then
      begin
        b[1]:=temp[1];
        inct2(l);
        inc(l);
        h:=temp[0];
        r:=2;
        for i1:=r to r-1+h do b[i1]:=temp[h-i1+r];
        r:=r-1+h;
      end
    else
      begin
        inct2(l);
        inc(l);
        h:=temp[0];
        r:=h-s+1;
        for i1:=1 to r do b[i1]:=temp[r+1-i1];
      end;
    inc(r);
    while r<50 do
      begin
        inct2(l);
        inc(l);
        h:=temp[0];
        for i1:=r to r-1+h do if i1<=50 then b[i1]:=temp[h-i1+r]else break;
        if r+h<50 then r:=r+h else r:=50;
      end;
    for i1:=50 downto 2 do
      begin
        c[i1]:=c[i1]+a[i1]+b[i1];
        if c[i1]>=10 then begin inc(a[i1-1]);c[i1]:=c[i1]mod 10;end;
      end;
    c[1]:=c[1]+a[1]+b[1];
    r:=c[1] mod 10;
    writeln(r);
  end;

begin
  readln(t);
  while t<>0 do
    begin
      main;
      readln(t);
    end;
end.
总是wa,不知为什么,郁闷ing

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