A solution in c++
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
long long int a, b, ck1=0,i,j,sum=0,sum1=0;
scanf("%lld",&a);
if(a%2==0){
ck1 = a/2;
printf("%lld\n", ck1);
}
else{
ck1 = (((a/2)+1)*(-1));
printf("%lld\n", ck1);
}
}


0 Comments
If you have any doubts, Please let me know