CSP-J2022解密
#include<bits/stdc++.h>
using namespace std;
int main(){
int k;
scanf("%d",&k);
for(int i=0;i<k;i++){
long long n,e,d;
scanf("%lld%lld%lld",&n,&e,&d);
long long j=n+2-e*d;
long long tt = j*j -4*n;
if(tt<0)
{
printf("NO\n");
continue;
}
long long st=sqrt(tt);
if(st*st != tt)
{
printf("NO\n");
continue;
}
long long first = st + j;
if(first%2 != 0)
{
printf("NO\n");
continue;
}
first/=2;
if(n%first != 0)
{
printf("NO\n");
continue;
}
long long two = n/first;
if(first > two)
{
long long tmp = first;
first = two;
two = tmp;
}
printf("%lld %lld\n",first,two);
}
return 0;
}