pls help me to correct remaining test cases
Pythagoras Triplet
#include #include using namespace std; int main() { int N; cin>>N; int m,n,X,Y,Z; X=(mm)-(nn); Y=2mn; Z=(mm)+(nn); if(N%2==0) { m=(N/2); n=1; X=((N/2)(N/2))-(11); Y=2*(N/2)1; Z=((N/2)(N/2))+(11); if(X<Z){ cout<<X<<" “<<Z<<endl;} else{ cout<<”-1"; } } else{ X=(((N+1)/2)((N+1)/2))-(((N-1)/2)((N-1)/2)); Y=2(((N+1)/2)((N-1)/2)); Z=(((N+1)/2)((N+1)/2))+(((N-1)/2)*((N-1)/2)); if(Y<Z) { cout<<Y<<" “<<Z<<endl;} else{ cout<<”-1"; } } }
@jontysingla85
You have missed the case when N<3 for which you have to print -1 and also there are mistakes in your formulas that you have used. Also you have to take all variable as long long.
I have made these changes to your code have a look.