-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLuogu_P_8814.cpp
35 lines (35 loc) · 897 Bytes
/
Luogu_P_8814.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/extc++.h>
using namespace std;
namespace pbds = __gnu_pbds;
using ui = unsigned int;
using uli = unsigned long long int;
using li = long long int;
using lli = __int128_t;
int main(void) {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
size_t T;
cin >> T;
while (T--) {
li n, d, e;
cin >> n >> d >> e;
li k = n - e * d + 2;
li a = -1, b = k, c = -n;
li tetha = b * b - 4 * a * c;
if (tetha < 0)
cout << "NO\n";
else {
double sq = sqrt(tetha);
double p = (-b + sq) / (2 * a);
double q = k - p;
if (p > q) swap(p, q);
if (lli(sq) * lli(sq) != tetha || p < 0)
cout << "NO\n";
else {
assert(!(li(round(p)) * li(round(q)) != n ||
li(round(p)) + li(round(q)) != k));
cout << li(round(p)) << ' ' << li(round(q)) << '\n';
}
}
}
return 0;
}