题目:[CSP-J 2022] 解密
题目原文请移步下面的链接
- https://www.luogu.com.cn/problem/P8814
- 参考题解:https://www.luogu.com.cn/problem/solution/P8814
- 标签:
数学
- 难度:
普及-
题解
思路
- 这道题难点在于公式推导,推导过程请参照下面链接的题解
- https://www.luogu.com.cn/problem/solution/P8814
代码
代码语言:javascript复制#include <bits/stdc .h>
using namespace std;
// 101 126 159
int main()
{
// freopen("decode.in", "r", stdin);
// freopen("decode.out", "w", stdout);
int k;
scanf("%d", &k);
long long n, d, e;
for (int j = 0; j < k; j) {
bool b = false;
scanf("%lld%lld%lld", &n, &d, &e);
long long m = n 2 - d * e;
long long q = (m sqrt(m * m - 4 * n)) / 2;
long long p = (m - sqrt(m * m - 4 * n)) / 2;
if (q p == m && q * p == n) {
printf("%lld %lldn", min(q, p), max(q, p));
} else {
printf("%sn", "NO");
}
}
// fclose(stdin);
// fclose(stdout);
return 0;
}
END