比赛 CSP2022普及组 评测结果 AAAAAAAAAA
题目名称 解密 最终得分 100
用户昵称 liuyiche 运行时间 1.147 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-10-29 15:15:01
显示代码纯文本
#include <bits/stdc++.h>  
 
using namespace std;
 
int k;

int main()
{
    freopen("csp2022pj_decode.in", "r", stdin);
	freopen("csp2022pj_decode.out", "w", stdout);
	
	cin >> k;
	
	for (int i = 1; i <= k; ++i)
	{
		long long n, e, d, paq, ff, pjq, p, q;
		cin >> n >> e >> d;
		paq = n+2-e*d;
		ff = paq*paq-4*n;
		if (ff < 0)
		{
			cout << "NO" << endl;
			continue;
		}
		pjq = (long long)sqrt(ff);
		if (pjq*pjq != ff)
		{
			cout << "NO" << endl;
			continue;
		}
		if ((paq-pjq)%2 != 0)
		{
			cout << "NO" << endl;
			continue;
		}
		q = (paq-pjq)/2;
		p = paq-q;
		if (q <= 0 || p <= 0)
		{
			cout << "NO" << endl;
			continue;
		}
		if (p > q)
		{
			long long c;
			c = p;
			p = q;
			q = c;
		}
		cout << p << " " << q << endl;
	}
	
    return 0;
}