Compiler Output Issue

Sir,
my program is giving the right output as per the test cases but still on submitting my code it displays test case #1,#2 : wrong-answer out of the 6 test cases

Hey @sagard0011
Can you post your code?

#include
#include<math.h>
using namespace std;

int main() {
long long int n,i,y=0;
float x;
cin>>n;
//for(i=0;i<(nn/2 + 1);i++)
while(n>2)
{
++y;
x = pow(y
y + nn,0.5);
if((x-(int)x)==0)
{
cout<<y<<" "<<x;
break;
}
}
if(n<=2)//(i==(n
n/2 + 1))
{
cout<<"-1";
}
return 0;
}

@sagard0011
Your code is not clear here, can you share in the form of coding blocks ide link and explain your approach?
Also, an alternate approach you can follow is:
If m>n>0 are integers, then (m2-n2, 2mn, m2-n2) is a Pythagorean triple. This is easily seen with a bit of algebra. Thus, plugging in various (m,n) will give various triples.
Now, our goal is to find a triple of the form (m2-n2, 2mn, m2-n2) in which our input value is one of the catheti. Note that the catheti are m2-n2 and 2mn. Also, note that the second cathetus is always even. Thus, it makes sense to consider two cases:

If a is even, then let’s try to equate it with the second cathetus, 2mn, i.e., let’s try to find an (m,n) pair such that 2mn = a. In this case, is even, so we can divide by 2. We have mn = a/2. Thus, all we have to do is to find a factorization of a/2 into mn such that m>n. You can try various factoring methods — even naïve O(√a) time method will pass - but in this case , we don’t really even need to do that, since the trivial (m,n) = (a/2,1) works!. This gives us the solution triple ( (a^2)/4 - 1, a, (a^2)/4 + 1 ). Note that (a^2)/4 is an integer since a is even.
If a is odd, then we can’t equate it with the second cathetus, so let’s try instead m2-n2, i.e. we want to find an (m,n) such that m2-n2 = a. Node that m2-n2 = (m+n)(m-n), so all boils down again to factoring! Let’s try our trivial factorization again: (m+n, m-n) = (a,1) What we get is a system of two linear equations: m+n=a and m-n=1 which has solution m=(a+1)/2 and n=(a-1)/2. Substituting back, this gives us the triple (a, (a^2 - 1)/2, (a^2 + 1)/2). Note that (a^2 + 1)/2 is an integer as a is odd.

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.