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

My code is wrong... Why?
Posted by Shatll 17 Dec 2002 23:23
I submit this problem and got WA?
Wazzup???

Var
  N, J, Sum: Integer;
  I: Word;
Begin
  Read (N);
  Sum:= 0;
  J:= 1;
  If N >= 1 Then Begin
    For I:= I to N do
      Sum:= Sum + I;
  End
  Else
    For I:= 1 to 2 + Abs (N) do Begin
      Sum:= Sum + J;
      Dec (J);
    End;
  WriteLn (Sum);
End.
Re: My code is wrong... Why?
Posted by XiaoTian 20 Dec 2002 20:03
> Var
>   N, J, Sum: Integer;
>   I: Word;
Your variables are too small. Just change 'Word' and 'Integer'
into 'LongInt', and then you will be right.