2018-09-29 14:39:19

# 顾z

## 分析

### 个人认为的坑点.

(代码自己看着都有点恶心.

(还是我没有看清题的说 emmm.

$\sqrt{(x_i-x_j) \times (x_i-x_j) +(y_i-y_j)\times (y_i-y_j))}$

------------------代码-------------------

#include<cstdio>
#include<iostream>
#include<cmath>
#define R register
using namespace std;
int n,m;
struct cod
{
char shape;
double a,b,c,d,r;
}s[508];
int main()
{
scanf("%d%d",&n,&m);
for(R int i=1;i<=n;i++)
{
cin>>s[i].shape;
switch(s[i].shape)
{
case 'r':
{
scanf("%lf%lf%lf%lf",&s[i].a,&s[i].b,&s[i].c,&s[i].d);
break;
}
case 'c':
{
scanf("%lf%lf%lf",&s[i].a,&s[i].b,&s[i].r);
break;
}
}
}
for(R int i=1;i<=m;i++)
{
R double x,y;R int cnt=0;
scanf("%lf%lf",&x,&y);
for(R int j=1;j<=n;j++)
{
if(s[j].shape=='c')
{
double dis=sqrt((s[j].a-x)*(s[j].a-x)+(s[j].b-y)*(s[j].b-y));
if(dis<s[j].r)
cnt++;
}
else
{
if(x==s[j].a or x==s[j].c)continue;
if(y==s[j].b or y==s[j].d)continue;
if(x>min(s[j].a,s[j].c) and x<max(s[j].c,s[j].a)and y<max(s[j].b,s[j].d) and y>min(s[j].d,s[j].b))
cnt++;
}
}
printf("%d\n",cnt);
}

}
• star
首页