#include
#include
using namespace std;
int main() {
int n, h, a, b;
cin>>n;
if(n%2 == 0)
{
h = ((n/2) * (n/2)) + 1;
a = ((n/2) * (n/2)) - 1;
b = 2* (n/2);
if((hh) == (aa) + (bb))
{
if(b==n)
cout<<min(h, a)<<" “<<max(h, a);
else
cout<<min(h, b)<<” “<<max(h,b);
}
else
{
cout<<”-1";
}
}
if(n%2 != 0)
{
h = ((n+1)/2) * ((n+1)/2) + ((n-1)/2) * ((n-1)/2);
a = ((n+1)/2) * ((n+1)/2) - ((n-1)/2) * ((n-1)/2);
b = ((n+1)/2 * (n-1)/2)2;
if((hh) == (aa) + (b*b))
{
if(a==n)
cout<<min(h, b)<<" “<<max(h, b);
else
cout<<min(h, a)<<” “<<max(h, a);
}
else
{
cout<<”-1";
}
}
return 0;
}
I got 60/100, and i am not getting where is the error?
Hello @rishaseth123,
There are 2 mistakes in your code:
Refer to the comments for better understanding.
Hope, this would help.
Give a like if you are satisfied.