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

1068
Posted by lestat 22 May 2004 00:48
I've sold it with the long solution, but I found a shorter one and I can't understand why it is not accepted.

var
  n,tmp:longint;
begin
  readln(n);
  if n>0 then
    write((((n+1)*n)/2))
    else
      write(-(((-n+1)*-n)/2)+1);
end.
How many times did you ran it?
Posted by Vlad Veselov 22 May 2004 17:51
You must write:
write((((n+1)*n)/2):0:0)
or use div 2 or shr 1 instead /2