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 1490. Fire Circle

Crash On #10
Posted by CHN_XT 14 Oct 2006 18:11
Help me!
Program Contest_B;
Var
  I, R : LongInt;
  Ans : Int64;
  Tmp : Extended;
Begin
  ReadLn(R);
  If R = 1 Then
    Ans := 4
  Else
    Begin
      Ans := 0;
      For I := R - 1 Downto 0 Do Begin
        Tmp := Sqrt(Sqr(R) - Sqr(I));
        If Tmp - Trunc(Tmp) <= 1E-9 Then
          Inc(Ans, Trunc(Tmp))
        Else
          Inc(Ans, Trunc(Tmp) + 1);
      End;
      Ans := Ans * 4;
    End;
  WriteLn(Ans);
End.
Re: Crash On #10
Posted by Tbilisi SU: Andrew Lutsenko 14 Oct 2006 20:11
>Tmp := Sqrt(Sqr(R) - Sqr(I));

Overflow of longint type for r>32768. And according to the statement r<=100000.
Re: Crash On #10
Posted by Mansurov Artur 16 Jul 2008 08:33
Дело не в этом
longint ограничен 2^31-1>2000000000
а вот inc не работает с типом int64