当前位置: 代码迷 >> 综合 >> 一道吓人的水题 HDU 1140
  详细解决方案

一道吓人的水题 HDU 1140

热度:68   发布时间:2024-01-20 20:19:57.0

题目意思很吓人。经过分析之后就变成了一道比大小的题目... 囧~

#include<set>
#include<iostream>
using namespace std;class Point3D{
public:double x,y,z;Point3D( double a=0,double b=0,double c=0 ){x=a; y=b; z=c;}
}A[111],B[111];double dis( Point3D a,Point3D b )
{return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}int main()
{int N,M;Point3D O(0,0,0);while( scanf("%d %d",&N,&M)!=EOF ){if( N==0&&M==0 )break;for( int i=0;i<N;i++ )scanf( "%lf %lf %lf",&A[i].x,&A[i].y,&A[i].z );for( int i=0;i<M;i++ )scanf( "%lf %lf %lf",&B[i].x,&B[i].y,&B[i].z );int ans=0;for( int j=0;j<M;j++ )for( int i=0;i<N;i++ ){if( dis(A[i],O)>dis(A[i],B[j])+dis(B[j],O) ){ans++;break;}}printf( "%d\n",ans );}return 0;
}