Pythagoras triplet

4th and 5th test i m getting TLE where the improvement needs to be done ?
question:
PYTHAGORAS TRIPLET
Given n , print its Pythagoras pair in increasing order if they exist. Otherwise print “-1”.

Input Format:
4 5

Constraints:
n <= 10^9

Output Format
Pythagoras Pair, x y

Sample Input
3
Sample Output
4 5

solution:https://ide.codingblocks.com/s/33526

Can anyone point out the mistake

You are moving b from A to AA.
which means complexity of your code is around O(A
A). which is around 10^18 which is huge and will certainly give TLE.

I am thinking to solve the problem by making use of:
(a+x)(a+x)-aa=nn
where n is given to us.

Solving this:
a=(nn-xx)/2*x
where x can range range from 1 to N-1.

so, if a is an integer, we will obtain a pythagoras pair (a,a+x).
This is solve the problem in around 10^9, which is still large and may give TLE.
Please provide me with the question link, or try coding this solution and let me know if this logic works for you.

Actually this question is given in course content here is the link for that:https://online.codingblocks.com/player/5682/content/5167?s=1435

I dont have the access to course link. So please try implementing my approach if you understood it.