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

what is the problem?!!
Posted by Prasanna 19 Feb 2002 09:58
whats problem with the code below?Judge is giving wrong answer.

#include<iostream.h>
main()
{
        long int n,sum;
        cin>>n;
        if(n<0)
                sum=1+n*(1-n)/2;
        else
                sum=n*(n+1)/2;
        cout<<sum;
}
Everyone who makes this problem can see that there are 3 cases, you just did 2 :) (-)
Posted by Miguel Angel 19 Feb 2002 10:37
Two is enough. Actually, it's possible to write one expression
Posted by Mephistos 19 Feb 2002 11:44
>
Try N==0
Posted by Mephistos 19 Feb 2002 11:50