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

why crash at test1?
Posted by l 27 Oct 2007 22:25
program ural1001(input,output);
var
  s:string;
  i,len:longint;
  n:int64;
  use:boolean;
  ans:array[1..500000] of real;
begin

  while not seekeof do
  begin
    readln(s);
    i:=1;
    repeat
      while s[i]=' ' do inc(i);
      n:=0;use:=false;
      while (s[i]>='0') and (s[i]<='9') and (i<=length(s)) do
      begin
        n:=n*10+ord(s[i])-48;
        inc(i);
        use:=true;
      end;
      if use then begin inc(len);ans[len]:=sqrt(n);end;
    until i>=length(s);
  end;
  for i:=len downto 1 do
    writeln(ans[i]:0:4);
end.
Re: why crash at test1?
Posted by Adrian Negreanu 2 Nov 2007 13:33
Use data types lika int64, double, extended to get such big numbers.

You should also use seekeoln.