ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

p1048 i got WA 100 times. please help me
Posted by I am david. Tabo. 25 Sep 2002 00:34
var i,j,k,l,y,o:longint;
    m,n,x,q,s,g,u:byte;
    a:array [0..100000] of longint;
    w:string;

begin
{  assign (input,'1048.txt');
  reset (input);
  assign (output,'1048.out');
  rewrite (output);}
  readln ({input,}k);
  x:=1;s:=0;l:=1;
  for i:=1 to k do
    begin
      readln (input,m,n);
      if (s=0)and(m=0)and(n=0) then
        begin
          inc(l);a[l]:=0;
          inc (y);s:=1;
        end
      else
        begin
          j:=j*10+(m+n);
          inc (x);
          s:=1;
          if x>9 then
            begin
              a[l]:=j;inc(l);
              j:=0;x:=1;inc (y);
            end
        end;
    end;
  if x<>1 then
    begin
      a[l]:=j;
      inc (y);
    end;
  for i:=y downto 1 do
    begin
      if q=1 then
        begin
          a[i]:=a[i]+1;
          q:=0;
        end;
      if (i=y)and(a[i-1]<>0) then
        begin
          q:=1;
          str (a[i],w);
          g:=length(w);
          o:=1;
          for u:=1 to g-1 do
            o:=o*10;
          a[i]:=a[i] mod o;
        end;
      if (a[i]>999999999)and(i<>1) then
        begin
          a[i]:=a[i]-1000000000;
          q:=1;
        end;
    end;
  for i:=1 to y do
    write ({output,}a[i]);
{  close (output);
  close (input);}
end.
Nice to meet you again.My friend
Posted by ECUST Multistar 25 Sep 2002 08:26
You Should Do this problem in another way.........

Don't you think is to dangours to use longint to calculate this

problem?