暴力累加被t了,搜了一波原来是要推公式的,弱智的一批
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <sstream>
using namespace std;
int main()
{
int t;
long long a,b;
cin>>t;
while(t--)
{
cin>>a>>b;
long long ans=0;
if(a%2!=0&&b%2!=0) ans=(a+b)/-2;
else if(a%2==0&&b%2!=0) ans=(b-a+1)/-2;
else if(a%2!=0&&b%2==0) ans=(b-a+1)/2;
else ans=a+(b-a)/2;
cout<<ans<<endl;
}
}