Problem 2144 Shooting Game

Problem 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

6
2 1
2 0 0 -1 0 0
-2 0 0 1 0 0
2 1
4 0 0 -1 0 0
-2 0 0 1 0 0
2 1
4 0 0 -1 0 0
1 0 0 1 0 0
2 1
1 1 1 1 1 1
-1 -1 -1 -1 -1 -1
1 1
0 0 0 1 0 0
3 1
-1 0 0 1 0 0
-2 0 0 1 0 0
4 0 0 -1 0 0
Sample Output

Case 1: 2 1
Case 2: 2 1
Case 3: 2 2
Case 4: 0 0
Case 5: 1 1

Case 6: 3 2

额,纠结了好久,不知道错哪儿了?

#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string.h>
using namespace std;
#define INF 1.e-5
#define Max 100010
struct seg
{
	double head,rear;
};
seg sg[Max];
bool cmp(seg a,seg b)
{
	if(a.head!=b.head)
	return a.head<b.head;
	else return a.rear<b.rear;
}
int main()
{
	//freopen("b.txt","r",stdin);
	int t,cas,n,i,tot,ans;
	double r,x,y,z,vx,vy,vz;
	double a,b,c,t1,t2;
	scanf("%d",&t);
	for(cas=1;cas<=t;cas++)
	{
		seg s;
		printf("Case %d: ",cas);
		tot=0;ans=1;
		scanf("%d %lf",&n,&r);
		for(i=1;i<=n;i++)
		{
			scanf("%lf %lf %lf %lf %lf %lf",&x,&y,&z,&vx,&vy,&vz);
			a=vx*vx+vy*vy+vz*vz;
			b=2*(x*vx+y*vy+z*vz);
			c=x*x+y*y+z*z-r*r;
			if(b*b-4*a*c>=0)
			{
				t1=(-b-sqrt(b*b-4*a*c))/(2*a);
				t2=(-b+sqrt(b*b-4*a*c))/(2*a);
				if(t2+INF>0)
				{
					s.head=t1;
					s.rear=t2;
					sg[tot]=s;
					tot++;
				}
			}
		}
		if(tot==0) {printf("%d %d\n",0,0);continue;}
		sort(sg,sg+tot,cmp);
		double tmp=sg[0].rear;
		for(i=1;i<tot;i++)
		{
			if(sg[i].head>tmp)
			{
				ans++;
				tmp=sg[i].rear;
			}
		}
		printf("%d %d\n",tot,ans);
	}
	return 0;
}
					






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值