rt.下面是代码
#include <bits/stdc++.h>
using namespace std;
int t,m,a,b,c,xc,fb,cx,cx1;
long double dert;
signed main(){
// freopen("uqe.in","r",stdin);
// freopen("uqe.out","w",stdout);
scanf("%lld%lld",&t,&m);
while(t--){
scanf("%lld%lld%lld",&a,&b,&c);
dert=max(b*b-4*a*c,4*a*c-b*b);
// cout<<dert<<endl;
if(a>0){
fb=b-2*b;
}
else{
fb=b;
}
if(b*b-4*a*c<0){
printf("NO\n");
continue;
}
cx1=1;
cx=1;
for(int i=2;dert!=int(dert);i++){
while(dert*i*i==int(dert*i*i)){
cx1*=i;
dert*=(i*i);
}
}
int dert1=dert;
for(int i=2;i*i<=dert1;i++){
while(dert1%(i*i)==0){
cx*=i;
dert1/=(i*i);
}
}
dert=dert1;
//cout<<cx<<endl;
if(dert==1||dert==0){
cx=cx*dert+fb;
xc=abs(2*a);
for(int i=2;i<=min(abs(xc),abs(cx));i++){
while(xc%i==0&&cx%i==0){
xc/=i;
cx/=i;
}
}
cout<<cx;
if(cx1*xc!=1&&cx!=0){
cout<<"/"<<cx1*xc;
}
cout<<endl;
}
else{
xc=abs(2*a);
for(int i=2;i<=min(abs(xc),abs(fb));i++){
while(xc%i==0&&fb%i==0){
xc/=i;
fb/=i;
}
}
if(fb!=0){
if(xc==1){
cout<<fb<<"+";
}
else{
cout<<fb<<"/"<<xc<<"+";
}
}
xc=abs(2*a);
for(int i=2;i<=min(abs(xc),abs(cx));i++){
while(xc%i==0&&cx%i==0){
xc/=i;
cx/=i;
}
}
if(cx!=1){
cout<<cx<<"*";
}
cout<<"sqrt("<<dert<<")";
if(cx1*xc!=1){
cout<<"/"<<cx1*xc;
}
cout<<endl;
}
}
return 0;
}
/*
9 1000
1 -1 0
-1 -1 -1
1 -2 1
1 5 4
4 4 1
1 0 -432
1 -3 1
2 -4 1
1 7 1
*/