FZU 2144 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
Sample Output
#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的更多相关文章
- FZU 2144 Shooting Game (贪心区域划分)
Problem 2144 Shooting Game Accept: 370 Submit: 1902 Time Limit: 1000 mSec Memory Limit : 32768 KB Pr ...
- ACM学习历程—FZU 2144 Shooting Game(计算几何 && 贪心 && 排序)
Description Fat brother and Maze are playing a kind of special (hentai) game in the playground. (May ...
- FZU 2144 Shooting Game(数学+贪心)
主要思路:求出蚊子到达球的时间区间(用方程得解),对区间做一个贪心的选择,选择尽可能多的区间有交集的区间段(结构体排序即可),然后计数. #include <cstdio> #includ ...
- Problem 2144 Shooting Game fzu
Problem 2144 Shooting Game Accept: 99 Submit: 465Time Limit: 1000 mSec Memory Limit : 32768 KB ...
- FZU 2137 奇异字符串 后缀树组+RMQ
题目连接:http://acm.fzu.edu.cn/problem.php?pid=2137 题解: 枚举x位置,向左右延伸计算答案 如何计算答案:对字符串建立SA,那么对于想双延伸的长度L,假如有 ...
- FZU 1914 单调队列
题目链接:http://acm.fzu.edu.cn/problem.php?pid=1914 题意: 给出一个数列,如果它的前i(1<=i<=n)项和都是正的,那么这个数列是正的,问这个 ...
- ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】
FZU 2105 Digits Count Time Limit:10000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- FZU 2112 并查集、欧拉通路
原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个连通分量,我们可以用一个并查集来维护,假设 ...
- ACM: FZU 2107 Hua Rong Dao - DFS - 暴力
FZU 2107 Hua Rong Dao Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
随机推荐
- 解决windows的控制台显示utf8乱码的问题
在控制台的属性里 修改自体为: 新宋体 在控制台下执行命令: chcp 65001
- web工程常见部署方式总结
作为一个web测试工程师,对测试所属的平台架构,项目部署情况应该是有所了解的,下面在此基础上总结下web项目在各种场景下常用的部署方式: 第一种方法: 开发常用部署方法,直接在myeclipse里部署 ...
- Sqlserver Sql Agent Job 只能同时有一个实例运行
Sqlserver Sql Agent中的Job默认情况下只能有一个实例在运行,也就是说假如你的Sql Agent里面有一个正在运行的Job叫"Test Job",如果你现在再去启 ...
- Openstack的的nova list命令
nova list用于在shell交互模式下查看当前用户存在的实例数目,但是这里仍然要注意的地方: 没有参数的nova list [root@node-5 newstest-master]# nova ...
- sql字段类型介绍
1 表格与储存引擎 表格(table)是数据库中用来储存纪录的基本单位,在建立一个新的数据库以后,你必须为这个数据库建立一些储存资料的表格: 每一个数据库都会使用一个资料夹,这些数据库资料夹用来储存所 ...
- jQuery.isNumeric() 和 js isNaN()
jQuery.isNumeric( value ) Description: 判断指定参数是否是一个数字值(字符串形式的数字也符合条件),返回 true 或者 false. Example: $.is ...
- Hibernate,Session方法使得java对象进入持久化状态;持久化对象特征
以下情况java对象进入持久化状态: session.save()方法把临时对象转变为持久化对象. session.load()和session.get()方法得到的对象总是处于持久化状态. sess ...
- 快速搭建Redis缓存数据库
之前一篇随笔——Redis安装及主从配置已经详细的介绍过Redis的安装于配置.本文要讲的是如何在已经安装过Redis的机器上快速的创建出一个新的Redis缓存数据库. 一.环境介绍 1) Linux ...
- get/post方式调用http接口
http://www.cnblogs.com/java-pan/tag/HTTP/ http://www.cnblogs.com/snoopylovefiona/p/4730242.html(可做参考 ...
- CentOS安装、卸载jdk
安装:http://www.mamicode.com/info-detail-613410.html 卸载:http://sunqiusong.email.blog.163.com/blog/stat ...