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 ...
随机推荐
- java 与 R 相互调用
https://www.r-project.org/ http://cos.name/2013/08/r-rjava-java/ http://blog.csdn.net/hwssg/article/ ...
- [Ubuntu] Linux下使用google app engine,无法打开https网站的解决方法
为什么这里写的是 google app engine?原因我就不解释了.步骤如下: 1)安装证书导入工具:$ sudo apt-get install libnss3-tools 2)导入CA.crt ...
- LR Socket 测试demo
建议像我这样最开始未接触过的,还是先从简单录制开始.录制完之后,分析测试脚本,再学习,再自己根据需要编写测试脚本. 第一:录制. A. B. 选择需要录制的exe的目录 ,填写完后点击ok. C ...
- Sqlserver Sql Agent Job 只能同时有一个实例运行
Sqlserver Sql Agent中的Job默认情况下只能有一个实例在运行,也就是说假如你的Sql Agent里面有一个正在运行的Job叫"Test Job",如果你现在再去启 ...
- MySQL函数汇总
前言 MySQL提供了众多功能强大.方便易用的函数,使用这些函数,可以极大地提高用户对于数据库的管理效率,从而更加灵活地满足不同用户的需求.本文将MySQL的函数分类并汇总,以便以后用到的时候可以随时 ...
- 启用 TStringGrid 的自画功能,并避免重影
FMX 控件的 TStringGrid 下,有时为了让不同行或不同 Cell 的显示颜色.字体等有各种不同的颜色, 必须采用自画, 即在其 OnDrawColumnCell 事件中写自己的控制代码显示 ...
- Linux TTY框架【转】
本文转载自:http://ju.outofmemory.cn/entry/281168 1. 前言 由于串口的缘故,TTY是Linux系统中最普遍的一类设备,稍微了解Linux系统的同学,对它都不陌生 ...
- ansible
3.1 配置 #vim /etc/ansible/hosts //定义主机,支持IP和域名,支持分组 [local] 127.0.0.1 [nginx] 192.168.0.10 ...
- post 405 method not allowed
HTTP 405 错误 – 方法不被允许 (Method not allowed) 介绍 HTTP 协议定义一些方法,以指明为获取客户端(如您的浏览器或我们的 CheckUpDown 机器人)所指定的 ...
- Pro ASP.NET MVC 5 Framework.学习笔记.6.3.MVC的必备工具
每个MVC程序员的军火库中,都有这三个工具:一个依赖注入(DI)容器,一个单元测试框架,一个模拟工具. 1.准备一个示例项目 创建一个ASP.NET MVC Web Application的Empty ...