My code is compiling with no error for pythagoras triplet problem and it is showing the results as mentioned in question but when i submit it 4 test cases are fail

what should i do to make it correct so that i pass all test cases. my code is working right with desired results but what i have to change in it so that it pass all test cases. below is my code.
############################################

#include
#include<math.h>
using namespace std;
int main(){
int n,i,j,k;
cin>>n;
if(n<=(10^9)){
if(n>0){
for(i=1;i<10;i++)
{
j=(nn)+(ii);
k=(pow(j,.5));
if(i==n and k==n and j%k==0){
cout<<-1;
break;
}
else if(j%k==0){
cout<<i<<" "<<k;
break;
}
}

	}
	else{
		for(i=-1;i>-10;i--)
		{
			j=(n*n)+(i*i);
			k=pow(j,.5);
			if(i==n and k==(-n) and j%k==0){
				cout<<-1;
				break;
			}
			else if(j%k==0){
				cout<<i<<" "<<-k;
				break;
			}
		}
		
	}
}
else{
	cout<<-1;
}
return 0;

}

@Rathi2000 you can use the property of pythagoras triplets that they are always of the form
(n * n - 1)/2, n, (n * n + 1)/2 (if n is odd)
((n * n)/4)-1, n, ((n * n)/4)+1) (is n is even)

In the future please share your code by saving it on ide.codingblocks.com

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.