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 ...
随机推荐
- appium python api收集
1.contexts contexts(self): Returns the contexts within the current session. 返回当前会话中的上下文,使用后可以识别H5页面的 ...
- mysql:Linux系统下mysql5.6的安装卸载
1.1. 下载rpm包 要使用yum 安装mysql,需要mysql的yum仓库,先从官网下载适合你系统的仓库 http://dev.mysql.com/downloads/repo/yum/ 我的是 ...
- 遇到的一些Jquery函数
jQuery.extend() jQuery.merge():函数用于合并两个数组内容到第一个数组. <script> $(function () { ,,], [,,] ...
- 数据绑定技术一:GridView控件
在网站或应用程序中,要显示数据信息,可用到ASP.NET提供的数据源控件和能够显示数据的控件. 一.数据源控件 数据源控件用于连接数据源.从数据源中读取数据以及把数据写入数据源. 1.数据源控件特点 ...
- 猎八哥浅谈MYSQL触发器
什么是MYSQL触发器,我们先了解一下触发的意思.触发的字面意思是指因触动而激发起某种反应. MYSQL必知必会中对触发器的解释是:MySQL响应以下任意语句而自动执行的一条MySQL语句(或位于 B ...
- CCIE-MPLS基础篇-实验手册
又一部前期JUSTECH(南京捷式泰)工程师职业发展系列丛书完整拷贝. MPLS(Multi-Protocol Label Switching) 目录 1:MPLS 基础实验.... 1.1实验拓扑. ...
- 当今游戏大作share的特性大盘点
极品游戏制作时的考虑要素大盘点 不知不觉入坑Steam已近4年,虽然说Steam的毒性让很多人走向一条不归路,但是想我这样即使"中毒"还是很快乐很感恩的.那么本期文章就谈谈我对其中 ...
- Node.js之eventproxy详解
安装 npm install eventproxy --save 调用 var EventProxy = require('eventproxy'); 异步协作 多类型异步协作 此处以页面渲染为场景, ...
- 结对编程1----基于java的四则运算生成器
小组成员:王震(201421123054).王杰(201421123055) Coding地址:https://git.coding.net/a506504661/sssss.git 一.题目描述 我 ...
- 结对编程1-四则运算GUI实现(58、59)
题目描述 我们在个人作业1中,用各种语言实现了一个命令行的四则运算小程序.进一步,本次要求把这个程序做成GUI(可以是Windows PC 上的,也可以是Mac.Linux,web,手机上的),成为一 ...