War on Weather

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 300    Accepted Submission(s): 162

Problem Description
After an unprovoked hurricane attack on the south shore, Glorious Warrior has declared war on weather. The first salvo in this campaign will be a coordinated pre-emptive attack on as many tropical depressions as possible. GW reckons that the attack will neutralize the tropical depressions before they become storms, and dissuade others from forming. 
GW has at his disposal k space-to-earth killer satellites at various locations in space. m tropical depressions are known to exist at various locations on the earth's surface. Each satellite can attack any number of targets on the earth provided there is line of sight between the satellite and each target. How many different targets can be hit? 
 
Input
The input consists of several test cases. Each case begins with a line containing integers 0 < k, m &le 100 as defined above. k lines follow, each giving x,y,z - the location in space of a satellite at the scheduled time of attack. m lines then follow, each giving x,y,z - the location of a target tropical depression. Assume the earth is a sphere centred at (0,0,0) with circumference 40,000 km. All targets will be on the surface of the earth (within 10-9 km) and all satellites will be at least 50 km above the surface. A line containing 0 0 follows the last test case. 
 
Output
For each test case, output a line giving the total number of targets that can be hit. If a particular target falls within 10-8 km of the boundary between being within line-of-sight and not, it may be counted either way. (That is, you need not consider rounding error so long as it does not exceed 10-8 km.) 
 
Sample Input
3 2
-10.82404031 -1594.10929753 -6239.77925152
692.58497298 -5291.64700245 4116.92402298
3006.49210582 2844.61925179 5274.03201053
2151.03635167 2255.29684503 5551.13972186
-1000.08700886 -4770.25497971 4095.48127333
3 4
0 0 6466.197723676
0 6466.197723676 0
6466.197723676 0 0
6366.197723676 0 0
6365.197723676 112.833485488 0
0 0 6366.197723676
0 -6366.197723676 0
0 0
 
Sample Output
2
3
 
Source
 
Recommend
Eddy   |   We have carefully selected several similar problems for you:  1145 1142 1154 1144 1143 

 
  计算几何的水题
  没有用到复杂的算法,用基本的几何知识即可解决这道题。
  题意:给你k个卫星的坐标,m个目标的坐标(在地球上),问能这些卫星能击中几个目标。卫星只能击中面对着地球的那一面,背对着它的那一面无法击中。
  思路:如果 卫星到目标的距离 > 卫星到切点的距离(作卫星到地球的切线,切线与地球的交点为切点),说明目标在当前卫星面对的地球的背面,无法击中。
  代码
 #include <iostream>
#include <cmath>
using namespace std;
//#define PI 3.1415926
#define PI acos(-1.0) //产生精确的圆周率PI
struct Point3{
double x,y,z;
};
double dist3(Point3 p0,Point3 p1)
{
return sqrt((p1.x-p0.x)*(p1.x-p0.x) + (p1.y-p0.y)*(p1.y-p0.y) + (p1.z-p0.z)*(p1.z-p0.z));
}
Point3 K[];
int main()
{
int k,m;
while(cin>>k>>m){
if(k== && m==) break;
double r = 40000.0 / ( * PI); //地球半径
int i;
for(i=;i<=k;i++)
cin>>K[i].x>>K[i].y>>K[i].z;
int sum = ; //记录有几个目标能被打击到
for(i=;i<=m;i++){
Point3 M; //目标
cin>>M.x>>M.y>>M.z;
Point3 o; //地球球心
o.x=,o.y=,o.z=;
int j;
for(j=;j<=k;j++){ //看哪个卫星能打到目标,找到了就立刻退出循环
double k2o = dist3(K[j],o); //当前卫星到地球球心的距离
double k2m = dist3(K[j],M); //卫星到目标的距离
if( k2m*k2m <= k2o*k2o-r*r )
break;
}
if(j<=k)
sum++;
}
cout<<sum<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

hdu 1140:War on Weather(计算几何,水题)的更多相关文章

  1. HDU 2096 小明A+B --- 水题

    HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...

  2. [HDU 2602]Bone Collector ( 0-1背包水题 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...

  3. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  4. hdu 2050:折线分割平面(水题,递归)

    折线分割平面 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  5. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  6. HDU 4706 Children's Day (水题)

    Children's Day Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  7. hdu 1201:18岁生日(水题,闰年)

    18岁生日 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. hdu 2025:查找最大元素(水题,顺序查找)

    查找最大元素 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  9. HDU 6300.Triangle Partition-三角形-水题 (2018 Multi-University Training Contest 1 1003)

    6300.Triangle Partition 这个题就是输出组成三角形的点的下标. 因为任意三点不共线,所以任意三点就可以组成三角形,直接排个序然后输出就可以了. 讲道理,没看懂官方题解说的啥... ...

随机推荐

  1. 获得客户端详细信息以及每个进程的sql语句

    db性能下降时很多朋友都想监控到是哪个客户端.哪个用户.哪台客户端发起的什么会话sql语句, 但是微软自带的要使用profiler才能实现,但是考虑性能问题,很多人不愿意! 网上有很多脚本能监控到客户 ...

  2. PotPlayer 进度条显示缩略图

      PotPlayer设置鼠标放在播放器进度条任意位置显示缩略图 迁移时间--2017年8月9日15:41:27Author:Marydon 右键-->选项(F5)-->点击左侧面板上的“ ...

  3. Linux平台Boost的编译方法

    本博客(http://blog.csdn.net/livelylittlefish)贴出作 者(三二一@小鱼)相关研究.学习内容所做的笔记,欢迎广大朋友指正! Linux平台Boost的编译方法 Bo ...

  4. Python-线程的生命周期

    线程的生命周期 所谓的xx生命周期,其实就是某对象的包含产生和销毁的一张状态图.线程的生命周期如下图所示: 各状态的说明如下: New新建.新创建的线程经过初始化后,进入Runnable状态. Run ...

  5. 推荐10款最常用的Android开发工具

    我们使用各种语言进行开发时,总是会用到各种各样的开发工具.有些开发工具是开发人员的必备品,有些则是为了提高开发效率而用.Android开发同样也会用到多种开发工具,供开发人员设计.创建.测试和发布程序 ...

  6. (一)Mina源代码解析之总体架构

    Apache Mina Server 是一个网络通信应用框架.也就是说,它主要是对基于TCP/IP.UDP/IP协议栈的通信框架(当然,也能够提供JAVA 对象的序列化服务.虚拟机管道通信服务等).M ...

  7. atitit.报表最佳实践oae 与报表引擎选型

    atitit.报表最佳实践oae 与报表引擎选型 1. 报表的主要的功能and结构 2 1.1. 查询设计器(配置化,metadata in html) ,anno 2 1.2. 查询引擎 2 1.3 ...

  8. gdb前端: VIM+Pyclewn 调试C/C++

    (gdb) mapkeys C-B : break "${fname}":${lnum} # set breakpoint at current line C-D : down C ...

  9. mysql操作及自动化运维

    备份恢复工具:percona-xtrabackup-2.0.0-417.rhel6.x86_64.rpm mysql主从配置命令: 主: 1.编辑主MYSQL 服务器的MySQL配置文件my.cnf, ...

  10. 源码分析HotSpot GC过程(二):DefNewGeneration的GC过程

    由于虚拟机的分代实现,虚拟机不会考虑各个内存代如何实现垃圾回收,具体的工作(对象内存的分配也是一样)由各内存代根据垃圾回收策略自行实现. DefNewGeneration的使用复制算法进行回收.复制算 ...