Description
Fat brother and Maze are playing a kind of special (hentai) game in the playground. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.) But as they don’t like using repellent while playing this kind of special (hentai) game, they really suffer a lot from the mosquito. So they decide to use antiaircraft gun to shoot the mosquito. You can assume that the playground is a kind of three-dimensional space and there are N mosquitoes in the playground. Each of them is a kind of point in the space which is doing the uniform linear motion. (匀速直线运动) Fat brother is standing at (0, 0, 0) and once he shoot, the mosquito who’s distance from Fat brother is no large than R will be shot down. You can assume that the area which Fat brother shoot is a kind of a sphere with radio R and the mosquito inside this sphere will be shot down. As Fat brother hate these mosquito very much, he wants to shoot as much mosquito as he can. But as we all know, it’s tired for a man to shoot even if he is really enjoying this. So in addition to that, Fat brother wants to shoot as less time as he can.
You can (have to) assume that Fat brother is strong enough and he don’t need to rest after shooting which means that can shoot at ANY TIME.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case starts with two integers N and R which describe above.
Then N lines follow, the ith line contains six integers ax, ay, az, dx, dy, dz. It means that at time 0, the ith mosquito is at (ax, ay, az) and it’s moving direction is (dx, dy, dz) which means that after time t this mosquito will be at (ax+dx*t, ay+dy*t, ax+dz*t). You can assume that dx*dx + dy*dy+ dz*dz > 0.
1 <= T <= 50, 1 <= N <= 100000, 1 <= R <= 1000000
-1000000 <= ax, ay, az <= 1000000
-100 <= dx, dy, dz <= 100
The range of each coordinate is [-10086, 10086]
Output
For each case, output the case number first, then output two numbers A and B.
A is the number of mosquito Fat brother can shoot down.
B is the number of times Fat brother need to shoot.
Sample Input
Sample Output
1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #include <algorithm> 5 using namespace std; 6 7 int n,m=0;double len; 8 struct point 9 { 10 double ax,ay,az,dx,dy,dz; 11 } wunzi[100010]; 12 struct time 13 { 14 double x,y; 15 16 } shijian[100010]; 17 18 void work(int i) 19 { 20 point p=wunzi[i]; 21 double a=p.dx*p.dx+p.dy*p.dy+p.dz*p.dz; 22 double b=2*(p.ax*p.dx+p.ay*p.dy+p.az*p.dz); 23 double c=p.ax*p.ax+p.ay*p.ay+p.az*p.az-len*len; 24 if(b*b-4*a*c<0) 25 return ; 26 double tool=b*b-4.0*a*c; 27 double ans1=(-b-sqrt(tool))/(2.0*a); 28 double ans2=(-b+sqrt(tool))/(2.0*a); 29 if(ans1<0&&ans2<0) return ; 30 if(ans1<0)ans1=0; 31 shijian[m].x=ans1,shijian[m].y=ans2; m++; 32 } 33 34 bool cmp(time p,time q) 35 { 36 return p.y<q.y; 37 } 38 int main() 39 { 40 int T,cas=1; 41 int i,j,k; 42 scanf("%d",&T); 43 while(T--) 44 { 45 m=0; 46 scanf("%d %lf",&n,&len); 47 for(i=0;i<n;i++) 48 { 49 scanf("%lf%lf%lf%lf%lf%lf",&wunzi[i].ax,&wunzi[i].ay,&wunzi[i].az,&wunzi[i].dx,&wunzi[i].dy,&wunzi[i].dz); 50 work(i); 51 } 52 sort(shijian,shijian+m,cmp); 53 int cnt=0,p; 54 for(i=0;i<m;i++) 55 { 56 p=i+1; 57 while(p<m && shijian[p].x<=shijian[i].y) 58 { 59 p++; 60 } 61 cnt++; 62 63 i=p-1; 64 } 65 printf("Case %d: %d %d ",cas,m,cnt); 66 cas++; 67 } 68 return 0; 69 }