解法如下:
int a, b;
scanf("%d%d", &a, &b);
if(a - b < 0) { //b > a
a += a % 2 != 0;
b -= b % 2 != 0;
cout << (a + b) * ((b - a) / 2 + 1) / 2 << endl;
} else { //a > b
a -= a % 2 != 0;
b += b % 2 != 0;
cout << (a + b) * ((a - b) / 2 + 1) / 2 << endl;
}