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...

BYF Who can give me some tests? [7] // Problem 1209. 1, 10, 100, 1000... 9 Nov 2002 18:47
Fechete Dan Ionut[dany] Re: Who can give me some tests? [3] // Problem 1209. 1, 10, 100, 1000... 9 Nov 2002 21:25
> for all numbers of form n*(n+1)/2+n+2 the answer is 1 and for the
the others is 0
Program Ural1209;
  Const Max=65536;
  Var
    Num:Array[0..Max] Of Longint;
    T:Array[1..Max] Of Byte;
    N,I,K,J,M:Longint;
  Begin
    I:=0;
    K:=0;
    J:=0;
    M:=0;
    FillChar(T,SizeOf(T),0);
    FillChar(Num,SizeOf(Num),0);
    Num[0]:=1;
    For I:=1 To Max Do Num[I]:=Num[I-1]+I;
    Readln(N);
    For I:=1 To N Do
      Begin
        Readln(K);
        If K<1000000000 Then M:=Trunc(Sqrt(K*2))
          Else M:=Trunc(Sqrt(K));
        If K>Num[Max] Then Begin T[I]:=0; Break; End;
        For J:=M-1 To Max-1 Do
          Begin
            If (K>Num[J]) And (K<Num[J+1]) Then Begin T[I]:=0; Break;
End
              Else If (Num[J]=K) Or (Num[J+1]=K) Then Begin T[I]:=1;
Break; End;
          End;
      End;
    For I:=1 To N Do
      If I<>N Then Write(T[I],' ')
      Else Write(T[I]);
  End.
Fechete Dan Ionut[dany] Re: Then why my program always get WA? [1] // Problem 1209. 1, 10, 100, 1000... 10 Nov 2002 19:26
I have no idea the same thing hapens to me too
ss here 's my formula :-) // Problem 1209. 1, 10, 100, 1000... 11 Nov 2002 19:04
if sum (sqtr(2*(K-1))) + 1 == K then K==1
else K==0
Fechete Dan Ionut[dany] Re: Who can give me some tests? // Problem 1209. 1, 10, 100, 1000... 9 Nov 2002 21:26
> for all numbers of form n*(n+1)/2+n+2 the answer is 1 and for the
the others is 0