题解 CF707C 【Pythagorean Triples】
规律题,分类讨论即可
所以初中数学解二元一次方程组
把每个结论带入就是答案
代码:
ll x;cin>>x;
if(x==1||x==2)puts("-1");
else{
if(x%3==0)printf("%lld %lld\n",x/3LL*4LL,x/3LL*5LL);
else if(x%4==0)printf("%lld %lld\n",x/4LL*3LL,x/4LL*5LL);
else if(x%5==0)printf("%lld %lld\n",x/5LL*3LL,x/5LL*4LL);
else if(x%2==0){
ll now=1;
while(x%2==0)x/=2,now*=2;
printf("%lld %lld\n",(x*x-1)/2*now,(x*x+1)/2*now);
}
else{
printf("%lld %lld\n",(x*x-1)/2,(x*x+1)/2);
}
}