#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;
}
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=((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.
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.