logo AlgoBeat OnlineJudge
登录 注册

Official Editorial

作者: 035966_L3  ·  发布于 2026-06-14 21:49:52  ·  最后修改于 2026-06-15 16:52:37
已通过
审核员:Lightning ING · 2026-06-15 16:52:37

https://scg3.piaoztsdy.cn/p/156

众所周知:

  • 对于 无解。
  • 以上式子中 为非负整数。

直接分情况讨论即可。

#include <bits/stdc++.h>
using namespace std;
int main()
{
	freopen("sd.in", "r", stdin);
	freopen("sd.out", "w", stdout);
	int T;
	cin >> T;
	while (T--)
	{
		long long n;
		cin >> n;
		if (!n)
		{
			cout << "0 0" << endl;
			continue;
		}
		switch (n % 4)
		{
			case 0:
			{
				cout << n / 4 + 1 << ' ' << n / 4 - 1 << endl;
				break;
			}
			case 2:
			{
				cout << "-1 -1" << endl;
				break;
			}
			default:
			{
				cout << n / 2 + 1 << ' ' << n / 2 << endl;
				break;
			}
		}
	}
	return 0;
}

暂无评论

登录 后即可评论。