#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll t;
scanf("%lld", &t);
while(t --) {
ll n, d, e;
scanf("%lld %lld %lld", &n, &d, &e);
ll m = n - d * e + 2;
ll p = m * m - 4 * n;
ll q = sqrt(p);
if(q * q == p)
q = q, p = p;
else
++ q;
if(q * q != p) {
cout << "NO" << endl;
continue;
}
else {
ll x = (m + q) / 2;
if(x * 2 != m + q) {
cout << "NO" << endl;
continue;
} else {
ll x2 = (m - q) / 2;
if(x2 * 2 != m - q) {
cout<<"NO"<<endl;
continue;
}
else {
if(x > x2)
printf("%lld %lld\n", x2, x);
else printf("%lld %lld\n", x, x2);
}
}
}
}
return 0;
}
P8814 [CSP-J 2022] 解密(民间数据)(题解)
最新推荐文章于 2024-05-23 17:21:42 发布