20分玄关求助
查看原帖
20分玄关求助
749958
yyb18660335329楼主2023/9/6 14:11

代码如下

#include<bits/stdc++.h>
using namespace std;
int ans=0;
struct Mch
{
	double x,y;
	int id=0;
	bool birth=0;
}machine[1005];
double getlong(double x1,double y1,double x2,double y2)
{
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}
int main()
{
	int n,k,t;
	cin>>n>>k>>t;
	for(int i=1;i<=n;i++)
	{
		cin>>machine[i].x>>machine[i].y;
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;
		cin>>x>>y;
		for(int j=1;j<=n;j++)
		{
			if(machine[i].x==x&&machine[i].y==y)
			{
				machine[i].birth=1;
				break;
			}
		}
	}
	for(int i=1;i<=t;i++)
	{
		int x,y,maxrode=0,maxid=0;
		cin>>x>>y;
		for(int i=1;i<=n;i++)
		{
			double rode=getlong(machine[i].x,machine[i].y,x,y);
			if(rode>maxrode)
			{
				maxid=i;
				maxrode=rode;
			}
		}
		if(machine[maxid].birth) ans++;
	}
	cout<<ans;
}
2023/9/6 14:11
加载中...