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

wa #2
Posted by ahmet terzi 25 Aug 2012 15:05
what's wrong in my code:
#include <stdio.h>

main()
{
      int a;
      scanf("%d",&a);
      if( a >= 0 )
          printf("%d",a*(a+1)/2);
      else
      {
          a = -a;
          printf("-%d",a*(a+1)/2-1);
      }
      return 0;
}

Edited by author 25.08.2012 15:05

Edited by author 25.08.2012 15:06
Re: wa #2
Posted by Ilian 18 Aug 2013 19:03
If a is 0,the answer IS 1, not 0.