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. java基础解析系列(四)---LinkedHashMap的原理及LRU算法的实现

    java基础解析系列(四)---LinkedHashMap的原理及LRU算法的实现 java基础解析系列(一)---String.StringBuffer.StringBuilder java基础解析 ...

  2. 解决nginx FastCGI sent in stderr: “Primary script unknown”

    今天重启了mac,突然发现本地的 lnmp 服务不能用了,什么请求都返回了: FastCGI sent in stderr: "Primary script unknown" 这个 ...

  3. 基于大数据的电影网站项目开发之CentOS的安装(一)

    一.下载VMware并安装,至于安装教程从网上搜索进行参考 二.下载系统镜像文件,这里使用的是CentOS-6.5-x86_64-bin-DVD1.iso 三.安装镜像文件 运行VMware work ...

  4. [UWP]理解及扩展Expander

    ##1. 前言 最近在自定义Expander的样式,顺便看了看它的源码. Expander控件是一个ContentControl,它通过IsExpanded属性或者通过点击Header中的Toggle ...

  5. C语言中指针*p[N], (*P)[N],及**p的区别

    在C语言编程中指针经常困扰着我们,但是若能灵活运用指针的话,将会使得我们编程变得更加轻松与高效.这里讲下*p[N], (*P)[N],及**p的区别,这也是之前经常困扰我的地方. 这三者的定义分别为: ...

  6. 从Object和Function说说JS的原型链

    ECMAScript规定了两个特殊的内置对象:Object和Function.他们的特殊性在于,他们本身既是对象又是函数,而他们同时也是对象和函数的构造器.这种自己生自己的逻辑显然违反人性,如果还停留 ...

  7. CCIE-MPLS基础篇-实验手册

    又一部前期JUSTECH(南京捷式泰)工程师职业发展系列丛书完整拷贝. MPLS(Multi-Protocol Label Switching) 目录 1:MPLS 基础实验.... 1.1实验拓扑. ...

  8. 转:【Java集合源码剖析】HashMap源码剖析

    转载请注明出处:http://blog.csdn.net/ns_code/article/details/36034955   您好,我正在参加CSDN博文大赛,如果您喜欢我的文章,希望您能帮我投一票 ...

  9. 个人作业3-(Alpha阶段)

    一. 总结自己的alpha 过程 1.团队的整体情况 Alpha阶段初期我们团队因分工以及项目具体实施一度茫然,好在在团队队长的带领下确认分工及制定具体计划,使任务有序的进行下去,中间过程虽然遇到一些 ...

  10. 201521123091 《Java程序设计》第12周学习总结

    Java 第十一周总结 第十一周的作业. 目录 1.本章学习总结 2.Java Q&A 3.码云上代码提交记录及PTA实验总结 4.课后阅读 1.本章学习总结 1.1 以你喜欢的方式(思维导图 ...