You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
330 B
C++

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int presum(int x)
{
return (x >> 1) - x * (x & 1);
}
int main()
{
int q, l, r;
scanf("%d", &q);
while (q--)
{
scanf("%d%d", &l, &r);
printf("%d\n", presum(r) - presum(l - 1));
}
return 0;
}