Problem 2144 Shooting Game fzu
Accept: 99 Submit: 465
Time Limit: 1000 mSec Memory Limit : 32768 KB
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
Sample Output
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <iostream>
#define eps 1e-8
using namespace std;
typedef struct abcd
{
double t1,t2;
} tii;
double Abs(double x){return x>?x:-x;}
int n,nu;
long long r;
tii ti[];
long long a[][];
bool cmp(tii x,tii y)
{
return x.t2<y.t2;
}
void fun(int k)
{
double aa=a[k][]*a[k][]+a[k][]*a[k][]+a[k][]*a[k][];
double b=*(a[k][]*a[k][]+a[k][]*a[k][]+a[k][]*a[k][]);
double c=a[k][]*a[k][]+a[k][]*a[k][]+a[k][]*a[k][]-r*r;
double d=b*b-*aa*c;
if(Abs(d)<eps)return ;
else
{
ti[nu].t1=(-b-sqrt(d))/(*aa);
ti[nu].t2=(-b+sqrt(d))/(*aa);
if(ti[nu].t1>ti[nu].t2)swap(ti[nu].t1,ti[nu].t2);
if(ti[nu].t1>=||ti[nu].t2>=)
{
if(ti[nu-].t1<)ti[nu-].t1=;
nu++;
}
}
}
int main()
{
//freopen("in.txt","r",stdin);
int t,i,j;
scanf("%d",&t);
for(i=; i<=t; i++)
{
nu=;
scanf("%d%I64d",&n,&r);
for(j=; j<n; j++)
{
scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&a[j][],&a[j][],&a[j][],&a[j][],&a[j][],&a[j][]);
fun(j);
}
sort(ti,ti+nu,cmp);
int ci=;
double now;
for (j=;j<nu;)
{
now=ti[j].t2;
ci++;
j++;
while(j<nu&&ti[j].t1<=now)j++;
}
printf("Case %d: %d %d\n",i,nu,ci);
}
}
Problem 2144 Shooting Game fzu的更多相关文章
- FZU 2144 Shooting Game (贪心区域划分)
Problem 2144 Shooting Game Accept: 370 Submit: 1902 Time Limit: 1000 mSec Memory Limit : 32768 KB Pr ...
- FZU 2144 Shooting Game
Shooting Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- 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 2278 YYS (FZU + java大数)
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2278 题目: 题意: 有n种卡牌,每种卡牌被抽到的概率为1/n,求收齐所有卡牌的天数的期望. 思路: 易推得公 ...
- Problem 2121 神庙逃亡(FZU)
Problem 2121 神庙逃亡 Accept: 700 Submit: 1788 Time Limit: 1000 mSec Memory Limit : 32768 KB Prob ...
- CODEVS_2144 砝码称重 2 折半搜索+二分查找+哈希
#include<iostream> #include<algorithm> #include<cstring> #include<map> #incl ...
- NOI.AC#2144-子串【SAM,倍增】
正题 题目链接:http://noi.ac/problem/2144 题目大意 给出一个字符串\(s\)和一个序列\(a\).将字符串\(s\)的所有本质不同子串降序排序后,求有多少个区间\([l,r ...
- (01背包 当容量特别大的时候) Knapsack problem (fzu 2214)
http://acm.fzu.edu.cn/problem.php?pid=2214 Problem Description Given a set of n items, each with a ...
随机推荐
- Python练习2
[之前发布到本人的51cto博客,现转过来] 无意看到老男孩的博文:合格linux运维人员必会的30道shell编程面试题及讲解 http://oldboy.blog.51cto.com/256141 ...
- python 二进制转换
#二进制装换msg = "大家好"msg1 = msg.encode(encoding='utf-8')#转换成二进制print(msg1)msg2 = msg1.decode(' ...
- 利用 FormData 对象和 Spring MVC 配合可以实现Ajax文件上载功能
Ajax文件上载 利用 FormData 对象和 Spring MVC 配合可以实现Ajax文件上载功能: 步骤 导入组件并准备静态脚本 <dependency> <groupId& ...
- JS基础-----JS中的分支结构及循环结构
[分支结构] 一.if-else结构 1.结构的写法:if(判断条件){ //条件为true时,执行if的{} }else{ //条件为false时,执行else的{} } 2.注意事项 ①else语 ...
- 猎八哥浅谈MYSQL触发器
什么是MYSQL触发器,我们先了解一下触发的意思.触发的字面意思是指因触动而激发起某种反应. MYSQL必知必会中对触发器的解释是:MySQL响应以下任意语句而自动执行的一条MySQL语句(或位于 B ...
- (1)ES6中let,const,对象冻结,跨模块常量,新增的全局对象介绍
1.let声明变量,var声明变量,而const声明的常量 2.let与var的区别 let可以让变量长期驻扎在内存当作 let的作用域是分块[ {快1 {快2 } }每个大括号表示一个独立的块 ...
- 201521123069 《Java程序设计》 第5周学习总结
1. 本章学习总结 1.1 尝试使用思维导图总结有关多态与接口的知识点. 1.2 可选:使用常规方法总结其他上课内容. 参考资料: 百度脑图 XMind 1.1 1.2 (1)用Arrays.sort ...
- 201521123009 《Java程序设计》第10周学习总结
1. 本周学习总结 2. 书面作业 本次PTA作业题集异常.多线程 Q1:finally 题目4-2 1.1 截图你的提交结果(出现学号) 1.2 4-2中finally中捕获异常需要注意什么? tr ...
- 201521123089 《Java程序设计》第13周学习总结
1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 1.协议:网络中为了进行数据交换而建立的原则,标准或约定. 2.域名:Internet上某一台计算机的名称 ...
- java 程序编写规则(自己总结)
1.命名规范 (1)所有的标示符都只能用ASCⅡ字母(A-Z或a-z).数字(0-9)和下划线"_". (2)类名是一个名词,采用大小写混合的方式,每个单词的首字母大写.例如:Us ...