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

Discussion of Problem 1001. Reverse Root

What is wrong? On my computer get the correct result (Pascal)
Posted by Timenzzo 19 Jun 2012 08:55
I'm worn out already. Lasarus compiled code. FPC version - 2.6.0. Get the right result. Send in the check, get - Wrong answer (test 3).

var c: char;
    i:longint;
    l:extended;
    numbers: array of extended;
begin
    l:=-1;
    SetLength(numbers,0);
    while not Eof do
      begin
        Read(c);
        if c in ['0'..'9'] then
          begin
            if l=-1 then l:=Ord(c)-48
            else
              l:=l*10+Ord(c)-48;
          end
        else
          begin
            if l<>-1 then
              begin
                SetLength(numbers,length(numbers)+1);
                numbers[length(numbers)-1]:=sqrt(l);
              end;
            l:=-1;
          end;
      end;
    for i:=length(numbers)-1 downto 0 do
      writeln(numbers[i]:0:4);
end.
Re: What is wrong? On my computer get the correct result (Pascal)
Posted by Thien Diep 26 Jun 2012 13:39
I think couldn't use array to save numbers because size of array not enought to contain. I think on your computer get the correct result because file input data only contain some value, not too much