Accepted 1140 0MS 252K 1380 B C++ 778477
枚举
嗯。。还有就是statistic里面我排第一。哎到底是代码写的好啊。效率那个高啊
#include <cstdio>
#include <cstring>
#include <cmath>
#define N 105
#define cir_dis 20000*1.0/3.1415926
struct point3D
{
double x,y,z;
point3D(double _x=0,double _y=0,double _z=0):x(_x),y(_y),z(_z){}
double Get_distocir()
{
return sqrt((x*x)+(y*y)+(z*z)-cir_dis*cir_dis);
}
double Get_dis(const point3D& b)
{
return sqrt((x-b.x)*(x-b.x) +
(y-b.y)*(y-b.y) +
(z-b.z)*(z-b.z));
}
};
point3D sate[N],target[N];
int main()
{
freopen("in.txt","r",stdin);
int k,m;
while(scanf("%d%d",&k,&m)!=EOF)
{
if(k==0 && m==0) break;
for(int i=0;i<k;i++)
scanf("%lf%lf%lf",&sate[i].x,&sate[i].y,&sate[i].z);
for(int i=0;i<m;i++)
scanf("%lf%lf%lf",&target[i].x,&target[i].y,&target[i].z);
bool vis[N];
memset(vis,false,sizeof(vis));
int ans = 0;
for(int i=0;i<k;i++)
{
for(int j=0;j<m;j++)
{
if(!vis[j])
{
double tmp = sate[i].Get_distocir();
double tmp_dis = sate[i].Get_dis(target[j]);
if(tmp_dis <= tmp)
{
ans++;
vis[j] = true;
}
}
}
}
printf("%d\n",ans);
}
return 0;
}