#include <bits/stdc++.h>
using namespace std;
int T, m, a, b, c, d, k, t, n, e;
void Main() {
cin >> a >> b >> c;
if(a < 0)
a = -a, b = -b, c = -c;
d = b * b - 4 * a * c, k = 1;
if(d < 0) {
cout << "NO\n";
return;
}
for(int i = 2; i * i <= d; i++)
while(d % (i * i) == 0)
k *= i, d /= i * i;
if(d == 0 || d == 1){
t = abs(__gcd(2 * a , -b + k * d));
cout << (-b + k * d) / t;
if(2 * a / t != 1)
cout << '/' << 2 * a / t;
cout << '\n';
return;
}
t = abs(__gcd(__gcd(-b, 2 * a), k));
b /= -t;
a = 2 * a / t;
k /= t;
n = abs(__gcd(a, b));
a /= n;
b /= n;
if(b){
if(b % a == 0) cout << b / a;
else cout << b << '/' << a;
cout << '+';
}
if(abs(k) == 1)
cout << "sqrt(" << d << ")";
else cout << abs(k) << "*sqrt(" << d << ")";
if(a == 1) cout << '\n';
else cout << '/' << a << '\n';
return;
}
int main() {
//freopen("P9750_9.in", "r", stdin);
//freopen("157.txt", "w", stdout);
for(cin >> T >> m; T; --T) Main();
return 0;
}
第9, 10个数据点过不了