全WA 0pts求调
查看原帖
全WA 0pts求调
758591
NEKO_Daze楼主2024/5/1 20:50

如下,测试样例能过,交上去就一片红WA (qAq

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a, b, k, m, t;
int main()
{
	cin >>t;
	while (t--)
	{
		cin >> a >> b >> k >> m;
		ll d = k * k + 4LL * (k-m+1LL);
		if (d < 0LL || (ll)sqrt(d) *(ll)sqrt(d) != d) cout << -1 << endl;
		ll x1 = (k-sqrt(d)) / 2LL, y1 = k - x1;
		ll x2 = (k+sqrt(d)) / 2LL, y2 = k - x2;
		if (0LL <= x1 && x1 < a && 0LL < y1 && y1 < b)
			cout << x1 << " " << y1 << endl;
		else if (0LL <= x2 && x2 < a && 0LL < y2 && y2 < b)
			cout << x2 << " " << y2 << endl;
		else cout << -1 <<endl;
	}
	return 0;
}
2024/5/1 20:50
加载中...