Problem 2144 Shooting Game

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

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
 
 
卡精度和输入要用long long,用int会爆
 #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的更多相关文章

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

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

  2. FZU 2144 Shooting Game

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

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

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

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

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

  5. Problem 2278 YYS (FZU + java大数)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2278 题目: 题意: 有n种卡牌,每种卡牌被抽到的概率为1/n,求收齐所有卡牌的天数的期望. 思路: 易推得公 ...

  6. Problem 2121 神庙逃亡(FZU)

    Problem 2121 神庙逃亡 Accept: 700    Submit: 1788 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Prob ...

  7. CODEVS_2144 砝码称重 2 折半搜索+二分查找+哈希

    #include<iostream> #include<algorithm> #include<cstring> #include<map> #incl ...

  8. NOI.AC#2144-子串【SAM,倍增】

    正题 题目链接:http://noi.ac/problem/2144 题目大意 给出一个字符串\(s\)和一个序列\(a\).将字符串\(s\)的所有本质不同子串降序排序后,求有多少个区间\([l,r ...

  9. (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 ...

随机推荐

  1. Weave 如何与外网通信?- 每天5分钟玩转 Docker 容器技术(66)

    上一节我们学习了 Weave 网络内部如何通信,今天讨论 Weave 如何与外界通信. weave 是一个私有的 VxLAN 网络,默认与外部网络隔离.外部网络如何才能访问到 weave 中的容器呢? ...

  2. eval浅解

    关于eval,你了解多少呢?来看看 eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码. 需要一个参数(string),切必需.要计算的字符串,其中含有要计算的 JavaS ...

  3. 第1阶段——uboot分析之硬件初始化start.S(4)

    分析uboot第一个执行函数_start(cpu/arm920t/start.S) 打开cpu/arm920t/start.S .globl _start // .globl定义一个全局符号" ...

  4. 基于NIOS-II的示波器:PART2 界面动态显示功能

    本文所有的硬件基础以及工程参考来自魏坤示波仪,重新实现驱动并重构工程. version 0.2 界面动态显示功能 界面显示功能原理 显示波形有如下两个方案: 每一帧直接重绘显示界面,再显示下一帧图形 ...

  5. Android学习记录:界面设计

    本片文章将记录进行android界面开发时积累的知识 包括 activity全屏 activity跳转 button设计 逐个输入编辑框设计 d0710 合并旧文章总结更新 d0721 添加内容 == ...

  6. 只查看tomcat进程,不包括grep

    ps aux | grep tomcat  | grep -v "grep" | awk '{print $2}'

  7. NHibernate教程(8)--巧用组件

    本节内容 引入 方案1:直接添加 方案2:巧用组件 实例分析 结语 引入 通过前面7篇的学习,有点乏味了~~~这篇来学习一个技巧,大家一起想想如果我要在Customer类中实现一个Fullname属性 ...

  8. MySQL (七)--视图、数据库备份和还原

    1 视图 视图:View,是一种有结构(有行有列)但是没结果(结构中不真实存放的数据)的虚拟表,虚拟表的结构来源不是自己定义,而是从对应的基表中产生(视图的数据来源). 示例脚本: CREATE TA ...

  9. 团队作业4——第一次项目冲刺(Alpha版本) 日志集合处

    第一天(2017.4.23) http://www.cnblogs.com/1413none/p/6752325.html 第二天(2017.4.24) http://www.cnblogs.com/ ...

  10. 201521123018 《Java程序设计》第6周学习总结

    1. 本章学习总结 2. 书面作业 一.clone方法 1.1 Object对象中的clone方法是被protected修饰,在自定义的类中覆盖clone方法时需要注意什么? 用protected修饰 ...