Pythagorean triplet

#include
#include<math.h>
using namespace std;
int main()
{
int n;
cin>>n;
long long int h,b;
while(n>3)
{
if(n%2==0)
{
h=((n/2)(n/2))+1;
b=((n/2)
(n/2))-1;
if(h==int(h) && b==int(b))
{
cout<<b<<endl;
cout<<h<<endl;
}
else
{
cout<<"-1"<<endl;
}
}
else if(n%2!=0)
{
h=((nn)+1)/2;
b=((n
n)-1)/2;
if(h==int(h) && b==int(b))
{
cout<<b<<endl;
cout<<h<<endl;
}
else
{
cout<<"-1"<<endl;
}
}
}
return 0;
}

@dsdishu99
What is your query here ?
And please use CB IDE to send code.

#include #include<math.h> using namespace std; int main() { int n; cin>>n; long long int h,b; while(n>3) { if(n%2==0) { h=((n/2)(n/2))+1; b=((n/2)(n/2))-1; if(h==int(h) && b==int(b)) { cout<<b<<endl; cout<<h<<endl; } else { cout<<"-1"<<endl; } } else if(n%2!=0) { h=((nn)+1)/2; b=((nn)-1)/2; if(h==int(h) && b==int(b)) { cout<<b<<endl; cout<<h<<endl; } else { cout<<"-1"<<endl; } } } return 0; }

the output is correct for the instance inputs given…

but it is not passing the testcases while submitting.

https://ide.codingblocks.com/s/190755 still not passing all the test cases…!

@dsdishu99
please see the logic here

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.