rt
主要思路是对每个点如果已经在范围内了就过了
没有的话比较对结果造成的增量
选较小的一个
相等的话让半径尽量大awa
#include <iostream>
using namespace std;
int ds(int a, int b, int x, int y)
{
return (a - x) * (a - x) + (b - y) * (b - y);
}
int main()
{
freopen("P1158_2.in", "r", stdin);
int x1, x2, y1, y2, d1 = 0, d2 = 0, n;
cin >> x1 >> y1 >> x2 >> y2 >> n;
for (int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
int dis1 = ds(x1, y1, x, y), dis2 = ds(x2, y2, x, y);
if (dis1 <= d1 || dis2 <= d2)
continue;
if (dis1 - d1 == dis2 - d2)
{
if (dis1 >= dis2)
d1 = dis1;
else
d2 = dis2;
}
else if (dis1 - d1 < dis2 - d2)
d1 = dis1;
else
d2 = dis2;
}
cout << d1 + d2;
return 0;
}