C++ 代码
#include<iostream>
using namespace std;
int main()
{
int n, x, y, sum = 0;
cin >> n;
for ( int i = 0; i < n; i++)
{
cin >> x >> y;
if ( x > y )
{
int tmp = x; x = y; y = tmp;
}
if ( x % 2 == 0)
{
x += 1;
if ( x < y )
sum += x;
}
while ( x + 2 < y)
{
x += 2;
sum += x;
}
cout << sum << endl;
sum = 0;
}
}