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

Solved
Posted by Marius Zilenas 11 Oct 2013 15:50
There is a catch, you should account for three situations:
1) N > 0
2) N < 0
3) N == 0 <--- 8-D.

Small assignment, but took an hour of trying.
Re: Solved
Posted by ძამაანთ [Tbilisi SU] 18 Oct 2013 17:10
you could just come up with the relatively less error-prone solution in one line
for(int i = 1; i!=N+2*(N>0)-1; i+=2*(N>0)-1) sum+=i;

Edited by author 16.11.2013 15:47