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 Navid 20 Feb 2016 21:12
Why does it keep saying wrong answer?

#include<stdio.h>
#include<math.h>

int main()

{
    int num,element_no;

    double sum;

    scanf("%d",&num);

    if(num<0)

    {
         element_no  = fabs(num) + 2;


    }

    else

    {
        element_no = num;
    }

    sum = (element_no/2.0) * (num + 1) ;


    int ans = sum;
    printf("%d\n",ans);

    return 0;
}