Pythagoras triplet

Can you give me a hint so that i dont exceed the time limit
#include
using namespace std;
int main(){
int n,x,y;
cin>>n;
int i=0;
for(x=1;x<=nn;x++)
{
if(i==1){
break;
}
else{
for(y=2;(y
y)<=(nn+xx);y++)
{
if((yy)==(nn+x*x))
{
cout<<x<<endl;
cout<<y<<endl;
i++;

            }
        }
    }
}
if(i==0){
    cout<<-1;
}
return 0;

}

firstly you take “long long int n” bcz of constraint but still this approach gives TLE bcz suppose n=99999993 then your code doesn’t works bcz of “data overflow” or “concept of wrap around”.

this is not good approach to solve these kinds of problems

Reference Code is :

logic is :

or
https://codingblocks.online/contents/edit/5931/lecture/1302

if you have further doubt feel free to ask

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.