Problem link : http://www.spoj.com/problems/PYTRIP/
I am not able to think of any other solution except brute force and also, i am unable to find any pattern or something. If anyone could please give me a hint in approaching the problem or provide a reference to any material that you think might be helpful would be great.
You can observe that a=sqrt(2*c-1) and b=c-1. Iterate from n to m and check for every i if sqrt(2*i-1)*sqrt(2*i-1) = 2*i-1. For c=1 there is no solution cause b=c-1=0.
C^2=a^2+b^2. So c^2-b^2=(c-b)(c+b)=a^2. You can say that c-b=1 and c+b=a^2. So c-b=1 => b=c-1. Now c+b=a^2 => 2*c-1=a^2. So a = sqrt(2*c-1).
I did for odd c here is full explanation http://codeforces.me/blog/entry/46681
You can use Euclid's formula