rt,不知道怎么回事
是有情况没对吗
#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++
using namespace std;
static char buf[1<<20],*p1=buf,*p2=buf;
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();return x*f;}inline void write(int x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+'0');}
bool memory_start;
int T, M;
int a, b, c;
bool memory_end;
int gcd(int a, int b)
{
return (b == 0) ? a : gcd(b, a % b);
}
signed main()
{
// freopen("x.in", "r", stdin);freopen("x.out", "w", stdout);
// printf("%.3f\n", (&memory_end - &memory_start) / 1024.0 / 1024);
//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> T >> M;
while (T --)
{
cin >> a >> b >> c;
int del = b * b - 4 * a * c;
if (del < 0){cout << "NO" << endl;continue;}
if (b == 0 && c == 0){cout << 0 << endl;continue;}
int f = 1, q_up = -b, q_dw = 2 * a;
int sq = sqrt(del);
if (sq * sq == del)
{
q_up += sq;
if (1.0 * q_up / q_dw < 0) f = -1;
q_up = abs(q_up), q_dw = abs(q_dw);
int g = gcd(q_up, q_dw);
q_up /= g, q_dw /= g;
if (f == -1) cout << "-";
if (q_dw == 1)
cout << q_up;
else
cout << q_up << "/" << q_dw;
putchar('\n');
continue;
}
if (b != 0)
{
if (1.0 * q_up / q_dw < 0) f = -1;
q_up = abs(q_up), q_dw = abs(q_dw);
int g = gcd(q_up, q_dw);
q_up /= g, q_dw /= g;
if (f == -1) cout << "-";
if (q_dw == 1)
cout << q_up << "+";
else
cout << q_up << "/" << q_dw << "+";
}
q_dw = abs(2 * a);
while (sq > 1)
{
if (del % (sq * sq) == 0) break;
sq --;
}
del = del / sq / sq;
int g = gcd(q_dw, sq);
sq /= g, q_dw /= g;
if (sq != 1) cout << sq << "*";
cout << "sqrt(" << del << ")";
if (q_dw != 1) cout << "/" << q_dw;
cout << '\n';
}
return 0;
}