我一次性AC这道题,用时10分钟。
#include<iostream>
using namespace std;
int main()
{
//freopen("xxx.in","r",stdin);
//freopen("yyy.out","w",stdout);
int N;
int x,y,t,he=0;
cin >> N;
for(int i=1;i<=N;i++)
{
he=0;
cin >> x >> y;
if(x>y)
{
t=x;
x=y;
y=t;
}
for(int j=x+1;j<y;j++)
{
if(j%2!=0)
{
he+=j;
}
}
cout << he << '\n';
}
//fclose(stdin);
//fclose(stdout);
return 0;
}