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. ios学习笔记(一)Windows7上使用VMWare搭建iPhone开发环境(转)

    原文地址:http://blog.csdn.net/shangyuan21/article/details/18153605 我们都知道开发iPhone等ios平台的移动应用时需要使用Mac本,但是M ...

  2. 使用sudo执行命令的时候提示找不到命令

    事出有因, 源自使用源码编译 nginx , 在 /usr/local/sbin/ 目录下创建了nginx 启动的符号链接 , 执行 sudo nginx 的时候提示找不到命令, 但是使用普通用户身份 ...

  3. zw版【转发·台湾nvp系列Delphi例程】HALCON DirectShow (Delphi Prism)

    zw版[转发·台湾nvp系列Delphi例程]HALCON DirectShow (Delphi Prism) namespace DirectShow_Prism;interfaceuses Sys ...

  4. fork系统调用(转载)

    (1) fork系统调用说明 fork系统调用用于从已存在进程中创建一个新进程,新进程称为子进程,而原进程称为父进程.fork调用一次,返回两次,这两个返回分别带回它们各自的返回值,其中在父进程中的返 ...

  5. asp.net项目发布网上-当前自定义错误设置禁止远程查看应用程序

    早上服务器的系统突然出错了,悲剧~ ==============异常信息:============================== 服务器上出现应用程序错误.此应用程序的当前自定义错误设置禁止远程 ...

  6. linux异步通信之epoll【转】

    转自:http://www.cnblogs.com/snake-hand/archive/2012/08/13/2636229.html 1.简介 epoll是linux提供的一种异步的I/O通知方式 ...

  7. nginx完美支持yii2框架

    nginx完美支持yii2框架 server {listen 80;server_name www.peita.net peita.net;# default_server;access_log /d ...

  8. asp.net导入Excel表

    一.导入Excel的界面这个界面很简单,代码就不列出来了.二.导入的代码我分了两部分,第一部分是点击查看数据的代码,这个是将数据导入到DataTable里面,但是还没有导入到数据库里.这里需要注意的是 ...

  9. jQuery - AJAX get() 和 post() 方法

    jQuery get() 和 post() 方法用于通过 HTTP GET 或 POST 请求从服务器请求数据. 参考网址: http://www.w3cschool.cc/jquery/jquery ...

  10. java用freemarker导出数据到word(含多图片)

    一.制作word模版 新建word文档,按照需要设置好字体等各种格式:这里为了显得整齐使用了无边框的表格. 将word文档另存为xml文件(注意不是word xml文档,我吃了这家伙的大亏了) 然后用 ...