Pythagoras Triplet Problem

I tried calculating the pythagorean pair by using (2m, m^2-1,m^2+1) where m is always an integer. I equate the given number with (2m , m^2-1,m^2+1) by hit and trial method and m comes out to be integer I simultaneously calculated the pair. But I could not get where I am going wrong.

#include<bits/stdc++.h>
using namespace std;

int main()
{
int N,m;
cin>>N;
float a=sqrt(N+1);
float b =sqrt(N-1);
if(N==1||N==2)
{
cout<<-1;
}
else if(N%2==0)
{
m = N/2;
cout<<(mm)-1<<" "<<(mm)+1;
}
else if(ceil(a)==floor(a))
{
cout<<(2a)<<" "<<(aa)+1;
}
else if(ceil(b)==floor(b))
{
cout<<2b<<" "<<(bb)-1;
}
else cout<< -1;

}

Hey, what is mm? It has not been defined anywhere. Also, save your code on ide.codingblocks.com and share the link here.

Hi, here is the link for my code : https://ide.codingblocks.com/s/67432

@sukh28 your code is not working for large no like eg 99999979 for this no output would be 4999999300000024 4999999300000025 but your code gives 19998 99980002 so try to optimise your code

Hey Sukhnandan,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

#include <bits/stdc++.h>
using namespace std;

int main() {
long long int a;
cin>>a;
int flag=0;
if(a%2 == 1){
long long int temp=(a*a) + 1;
long long int b=(temp/2)-1;
long long int c=temp/2;

     if(a*a + b*b == c*c){
             flag=1;
             cout<<b<<" "<<c<<endl;
   }
}
else{
    long long int b1=a*a/4;
    long long int x=b1-1;
    long long int y=b1+1;
    if(a*a + x*x == y*y){
        flag=1;
        cout<<x<<" "<<y<<endl;
                	}
}
if(flag == 0 || a==0 || a==1 || a==2){
    cout<<-1<<endl;
}
return 0;

}

getting WA in one case, can anyone help?

@Himanish hey himanish there is silly mistake in your code . I have modified your code the mistake is that if a=0 your code is printing -1
0 1
but it should print -1
you correct code is this.