当前位置: 首页 > backend >正文

E - Shooting Game FZU - 2144

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


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;const double eps=1e-9;
const int maxn=1e5+10;
struct node{double x,y,z;double vx,vy,vz;node(){	}node(double _x,double _y,double _z,double _vx,double _vy,double _vz){x=_x,y=_y,z=_z,vx=_vx,vy=_vy,vz=_vz;}
}p[maxn];
struct SEG{double st,ed;bool operator<(const SEG& b)const{if(fabs(st-b.st)<=eps)return ed>b.ed; return st<b.st;}
}arr[maxn]; 
/*
注意无解的情况 
*/
int check(int i,double& st,double& ed,double R){double A=(p[i].vx*p[i].vx+p[i].vy*p[i].vy+p[i].vz*p[i].vz),B=2.0*(p[i].x*p[i].vx+p[i].y*p[i].vy+p[i].z*p[i].vz),C=(p[i].x*p[i].x+p[i].y*p[i].y+p[i].z*p[i].z)-R*R;if(B*B-4.0*A*C<0) return 0;//忘了没解的情况 double ans2=(-B+sqrt(B*B-4.0*A*C))/(2.0*A);if(ans2<0) return 0;double ans1=max(0.0,(-B-sqrt(B*B-4.0*A*C))/(2.0*A));st=ans1,ed=ans2;//printf("A:%f B:%f C:%f\n",A,B,C);return 1; 
}/*
??????卡时间,直接按照doube输入超时,得用int再转化。
*/
int main(){int T,kase=1;scanf("%d",&T);while(T--){int n;double r;scanf("%d %lf",&n,&r);for(int i=1;i<=n;i++){int x,y,z,dx,dy,dz;scanf("%d %d %d %d %d %d",&x,&y,&z,&dx,&dy,&dz);p[i]=node(x*1.0,y*1.0,z*1.0,dx*1.0,dy*1.0,dz*1.0);}int cnt=0;for(int i=1;i<=n;i++){double st,ed;if(check(i,st,ed,r)){arr[cnt].st=st,arr[cnt++].ed=ed;}} if(cnt==0){printf("Case %d: %d %d\n",kase++,0,0);continue;}sort(arr,arr+cnt);int ans=1;double max_line=arr[0].ed;for(int i=1;i<cnt;i++){if(arr[i].st>max_line){ans++;max_line=arr[i].ed;}max_line=min(max_line,arr[i].ed);}printf("Case %d: %d %d\n",kase++,cnt,ans);} return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;const double eps=1e-9;
const int maxn=1e5+10;
struct node{double x,y,z;double vx,vy,vz;node(){	}node(double _x,double _y,double _z,double _vx,double _vy,double _vz){x=_x,y=_y,z=_z,vx=_vx,vy=_vy,vz=_vz;}
}p[maxn];
struct SEG{double st,ed;bool operator<(const SEG& b)const{return ed<b.ed;}
}arr[maxn]; int check(int i,double& st,double& ed,double R){double A=(p[i].vx*p[i].vx+p[i].vy*p[i].vy+p[i].vz*p[i].vz),B=2.0*(p[i].x*p[i].vx+p[i].y*p[i].vy+p[i].z*p[i].vz),C=(p[i].x*p[i].x+p[i].y*p[i].y+p[i].z*p[i].z)-R*R;if(B*B-4.0*A*C<0) return 0;//忘了没解的情况 double ans2=(-B+sqrt(B*B-4.0*A*C))/(2.0*A);if(ans2<0) return 0;double ans1=max(0.0,(-B-sqrt(B*B-4.0*A*C))/(2.0*A));st=ans1,ed=ans2;//printf("A:%f B:%f C:%f\n",A,B,C);return 1; 
}
/*
4
2 1
1 1 1 1 1 1
-1 -1 -1 -1 -1 -1
1 1
2 0 0 0 1 0
*//*
??????卡时间,直接按照doube输入超时,得用int再转化。
*/
int main(){int T,kase=1;scanf("%d",&T);while(T--){int n;double r;scanf("%d %lf",&n,&r);for(int i=1;i<=n;i++){int x,y,z,dx,dy,dz;scanf("%d %d %d %d %d %d",&x,&y,&z,&dx,&dy,&dz);p[i]=node(x*1.0,y*1.0,z*1.0,dx*1.0,dy*1.0,dz*1.0);}int cnt=0;for(int i=1;i<=n;i++){double st,ed;if(check(i,st,ed,r)){arr[cnt].st=st,arr[cnt++].ed=ed;//	printf("st:%f ed:%f\n",st,ed);}} if(cnt==0){printf("Case %d: %d %d\n",kase++,0,0);continue;}sort(arr,arr+cnt);int ans=1;double max_line=arr[0].ed;for(int i=1;i<cnt;i++){if(arr[i].st>max_line){ans++;max_line=arr[i].ed;}}printf("Case %d: %d %d\n",kase++,cnt,ans);} return 0;
}

http://www.xdnf.cn/news/11348.html

相关文章:

  • 【CBAP50技术手册】#34 Process Analysis(流程分析):业务分析师的“优化镜头”
  • inno setup介绍
  • KMP算法精讲
  • 电脑联网跳msftconnecttest(无论是不是校园网)
  • Genymotion中文手册,Genymotion配置
  • 在ubuntu下安装mysql
  • 如何快速绘制一张业务流程图?8张实操案例帮你快速上手!
  • 自动跳转到www.0749.com网页问题
  • Java IDEA JUnit 单元测试
  • XMLHttpRequest的五种状态描述——常见的请求头和相应头都有什么——reflow(回流)repaint(重绘)引起变换的原因
  • 转:LaTeX 换行换页与段落命令与图书模板
  • InstallShield使用完全教程
  • ADB安装及使用详解(非常详细)从零基础入门到精通,看完这一篇就够了
  • 多个域名可以指向同一个主机ip地址_一文彻底搞懂外贸网站相关的域名设置
  • IMP ORA-20005: object statistics are locked(二)
  • WAP页上传图片
  • 15个Python兼职接单平台!利用业余时间赚钱
  • 捷克论坛新ip_兰峰:提升哈尔滨冰雪文化IP打造能力
  • emule最新服务器地址,emule 国内服务器(最新emule服务器)
  • 提升C# 写入Excel操作的效率方式
  • LoadRunner压力测试方法
  • 高分卫星系列介绍及其传感器参数
  • MySQL基础入门教程(非常详细)从零基础入门到精通,看完这一篇就够了
  • 操作系统——缓冲区(buffer)与缓存(cache)
  • scrum回顾_敏捷,Scrum框架入门一篇文章就够了
  • mingw64环境搭建
  • Node.js 的常用命令介绍
  • 极域电子教室破解!
  • 深度学习网络 | GoogleNet v1-v3解析(1)
  • 192.168.1.1随身wifi登录器