答案来了
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1000000000;
ll mysqrt (ll x){
if(x<0){
return -1;
}
ll y=sqrt(x);
if(y*y==x){
return y;
}
else{
return -1;
}
}
int T;
int main(){
scanf("%d",&T);
for(int tc=1;tc<=T;tc++){
ll n,e,d;
scanf("%lld%lld%lld",&n,&e,&d);
ll m=n-e*d+2;
ll y=mysqrt(m*m-4*n);
if(y==-1){
printf("NO\n");
}
else{
ll p=(m-y)/2,q=(m+y)/2;
if(p*q==n&&p+q==m&&p>0&&q>0){
printf("%lld %lld\n",p,q);
}
else{
printf("No\n");
}
}
}
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1000000000;
ll mysqrt (ll x){
if(x<0){
return -1;
}
ll y=sqrt(x);
if(y*y==x){
return y;
}
else{
return -1;
}
}
int T;
int main(){
scanf("%d",&T);
for(int tc=1;tc<=T;tc++){
ll n,e,d;
scanf("%lld%lld%lld",&n,&e,&d);
ll m=n-e*d+2;
ll y=mysqrt(m*m-4*n);
if(y==-1){
printf("NO\n");
}
else{
ll p=(m-y)/2,q=(m+y)/2;
if(p*q==n&&p+q==m&&p>0&&q>0){
printf("%lld %lld\n",p,q);
}
else{
printf("No\n");
}
}
}
}