Shooting Game

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

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 <string.h>
#include <math.h>
#include <algorithm>
using namespace std; int n,m=;double len;
struct point
{
double ax,ay,az,dx,dy,dz;
} wunzi[];
struct time
{
double x,y; } shijian[]; void work(int i)
{
point p=wunzi[i];
double a=p.dx*p.dx+p.dy*p.dy+p.dz*p.dz;
double b=*(p.ax*p.dx+p.ay*p.dy+p.az*p.dz);
double c=p.ax*p.ax+p.ay*p.ay+p.az*p.az-len*len;
if(b*b-*a*c<)
return ;
double tool=b*b-4.0*a*c;
double ans1=(-b-sqrt(tool))/(2.0*a);
double ans2=(-b+sqrt(tool))/(2.0*a);
if(ans1<&&ans2<) return ;
if(ans1<)ans1=;
shijian[m].x=ans1,shijian[m].y=ans2; m++;
} bool cmp(time p,time q)
{
return p.y<q.y;
}
int main()
{
int T,cas=;
int i,j,k;
scanf("%d",&T);
while(T--)
{
m=;
scanf("%d %lf",&n,&len);
for(i=;i<n;i++)
{
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);
work(i);
}
sort(shijian,shijian+m,cmp);
int cnt=,p;
for(i=;i<m;i++)
{
p=i+;
while(p<m && shijian[p].x<=shijian[i].y)
{
p++;
}
cnt++; i=p-;
}
printf("Case %d: %d %d\n",cas,m,cnt);
cas++;
}
return ;
}

FZU 2144 Shooting Game的更多相关文章

  1. FZU 2144 Shooting Game (贪心区域划分)

    Problem 2144 Shooting Game Accept: 370 Submit: 1902 Time Limit: 1000 mSec Memory Limit : 32768 KB Pr ...

  2. ACM学习历程—FZU 2144 Shooting Game(计算几何 && 贪心 && 排序)

    Description Fat brother and Maze are playing a kind of special (hentai) game in the playground. (May ...

  3. FZU 2144 Shooting Game(数学+贪心)

    主要思路:求出蚊子到达球的时间区间(用方程得解),对区间做一个贪心的选择,选择尽可能多的区间有交集的区间段(结构体排序即可),然后计数. #include <cstdio> #includ ...

  4. Problem 2144 Shooting Game fzu

    Problem 2144 Shooting Game Accept: 99    Submit: 465Time Limit: 1000 mSec    Memory Limit : 32768 KB ...

  5. FZU 2137 奇异字符串 后缀树组+RMQ

    题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...

  6. FZU 1914 单调队列

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...

  7. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  8. FZU 2112 并查集、欧拉通路

    原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个连通分量,我们可以用一个并查集来维护,假设 ...

  9. ACM: FZU 2107 Hua Rong Dao - DFS - 暴力

    FZU 2107 Hua Rong Dao Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

随机推荐

  1. MapReduce之Mapper类,Reducer类中的函数(转载)

    Mapper类4个函数的解析 Mapper有setup(),map(),cleanup()和run()四个方法.其中setup()一般是用来进行一些map()前的准备工作,map()则一般承担主要的处 ...

  2. notification 通知

    1. 定义一个方法 -(void) update{ } 2. 对象注册,并关连消息 [[NSNotificationCenter defaultCenter]addObserver:self sele ...

  3. iOS 警告窗口

    - (IBAction)buttonPressed:(id)sender {        NSDate *date=self.datePicker.date;    NSString *messag ...

  4. laravel的安装

    安装composer http://docs.phpcomposer.com/download/ curl -sS https://getcomposer.org/installer | php mv ...

  5. weblogic从应用服务器找不到主应用服务器

    报错信息: weblogic.cluster.replication.ApplicationUnavailableException: WebApp with contextPath: not fou ...

  6. C#:实现接口中定义的事件

    public delegate void TestDelegate(); // delegate declaration public interface ITestInterface { event ...

  7. js比typeof更准确的验证类型方法

    var type = function (o){ var s = Object.prototype.toString.call(o); return s.match(/\[object (.*?)\] ...

  8. 将turnserver设定成开机启动

    1.创建一个文件,在目录/etc/init/下面 #sudo vim /etc/init/turnserver.conf 2.添加如下内容 description "turn server& ...

  9. The shortest problem

    The shortest problem Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...

  10. Reflection实现通用增删改

    新增 /// <summary> /// 通用新增方法 /// </summary> /// <param name="arr">一行数据封装的 ...