Home > Back-end >  Code blocks stray examples are right, but submit OJ said my examples are wrong, try for a long time,
Code blocks stray examples are right, but submit OJ said my examples are wrong, try for a long time,

Time:11-07

# include
H # include

Unsigned long long sum (int a, int b)
{
Unsigned long long sum=0;
If (a + b> 0)
{
If (a <0 && b> 0)
Sum=(fabs (a) + 1 + b) * (b - fabs (a))/2;
The else
Sum=(a + b) * (b - a + 1)/2;
}
Else if (a + b <0)
{
If (a <0 && b> 0)
Sum=(b + 1 + fabs) (a) * (fabs (a), b)/2;
The else
Sum=(fabs + fabs (b) (a)) * (fabs (a) - fabs (b) + 1)/2;
}
The else
Sum=0;
return sum;
}
Int main ()
{
Int a, b, n.
scanf("%d",&n);
for(int i=1; i<=n; I++)
{
The scanf (" % d % d ", & a & b);
If (a <0 && b> 0 && a + b <0 | | <0 && b <0)
Printf (" % llu \ n ", sum (a, b));
The else
Printf (" % llu \ n ", sum (a, b));
printf("\n");
}
return 0;
}
  • Related