40分求助!!!
查看原帖
40分求助!!!
844496
J_Kobe楼主2023/8/15 08:15
#include <bits/stdc++.h>
using namespace std;

int n, k, t;

struct node
{
	int x, y;
	int f;
} a[2005];

int star(int x, int y, int z, int w)
{
	return sqrt(abs(x - z) * abs(x - z) + abs(y - w) * abs(y - w));
}

int main()
{
    cin >> n >> k >> t;
    for (int i = 1; i <= n; i++)
    {
    	cin >> a[i].x >> a[i].y;
	}
	for (int i = 1; i <= k; i++)
	{
		int x, y;
		cin >> x >> y;
		for (int j = 1; j <= n; j++)
		{
			if (a[j].x == x && a[j].y == y)
			{
				a[i].f = 1;
			}
		}
	}
	int res = 0;
	for (int i = 1; i <= t; i++)
	{
		int x, y;
		cin >> x >> y;
		int flag = -1, ans;
		for (int j = 1; j <= n; j++)
		{
			if (star(x, y, a[j].x, a[j].y) > flag)
			{
				ans = j;
				flag = star(x, y, a[j].x, a[j].y);
			}
		}
		if (a[ans].f)
		{
			res++;
		}
	}
	cout << res;
    return 0;
}

上面的是我的代码,只有40分,请各位大佬帮我看看

2023/8/15 08:15
加载中...