Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int s = 0;
int e = 0;
int t = 0;
for (int i = 0; i < n; i ++)
{
s = cin.nextInt();
e = cin.nextInt();
if (s > e)
{
int temp = s;
s = e;
e = temp;
}
t = 0;
for (int j = s + 1; j < e; j ++)
{
if (j % 2 != 0)
t += j;
}
System.out.println (t);
}
}
}