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 1209. 1, 10, 100, 1000...

HELP!!! Crash (floating-point invalid operation) #3 test.....
Posted by Swifty 17 Mar 2009 19:45
Here is my code. Can't understand my mistake.
var i,n,k:word;
    m:real;
begin
  readln(n);
  for i:=1 to n do
   begin
     readln(k);
     m:=(sqrt(8*k-7)-1)/2;
     if (frac(m))=0.0 then write('1 ')
                      else write('0 ');
   end;
   readln;
end.
Re: HELP!!! Crash (floating-point invalid operation) #3 test.....
Posted by Shyu SeiMin 2 Jun 2009 11:23
So did I.
But I am AC now.
-----------------------------------------------
program  p1196;
var
  i,n:longint;
  a,b:qword;        //point
begin
  readln(n);
  for i:=1 to n do
    begin
      readln(a);
      b:=trunc(sqrt((a-1)*2));
      if (a-1)*2=b*(b+1)
        then write(1,' ')
        else write(0,' ');
    end;
end.