Akbar teacher#12290

Akbar teacher (Editorial)

Problem Author:

Omar Alimammad

Prepared by:

Hasan Saleh (MathModel)

Edited by:

Hasan Saleh (MathModel)

Solution

The problem can be formulated to the following problem :

Let then for which it holds :

a+x = b-x \implies a+2x=b \implies b-a=2x

thus a solution only exist if b-a is even which is x=\frac{b-a}{2} otherwise the answer is .

Complexity .

for _ in range(int(input())):
    a,b=map(int,input().split())
    if(abs(a-b)%2==0):
        print((abs(a-b))//2)
    else:
        print(-1)