hdu 1140:War on Weather(计算几何,水题)
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
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?
#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(计算几何,水题)的更多相关文章
- HDU 2096 小明A+B --- 水题
HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...
- [HDU 2602]Bone Collector ( 0-1背包水题 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...
- hdu 2117:Just a Numble(水题,模拟除法运算)
Just a Numble Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu 2050:折线分割平面(水题,递归)
折线分割平面 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- hdu 2044:一只小蜜蜂...(水题,斐波那契数列)
一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...
- HDU 4706 Children's Day (水题)
Children's Day Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1201:18岁生日(水题,闰年)
18岁生日 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- hdu 2025:查找最大元素(水题,顺序查找)
查找最大元素 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- HDU 6300.Triangle Partition-三角形-水题 (2018 Multi-University Training Contest 1 1003)
6300.Triangle Partition 这个题就是输出组成三角形的点的下标. 因为任意三点不共线,所以任意三点就可以组成三角形,直接排个序然后输出就可以了. 讲道理,没看懂官方题解说的啥... ...
随机推荐
- percona XTRADB Cluster 5.6在ubuntu安装
installing-perconaXTRADB Cluster 5.6 in-ubuntu-13-10-wheezy First of all, I would recommend login as ...
- 【Django】ImportError: cannot import name 'execute_manager'
错误描述 在使用Django 2.0 启动项目的时候,报错如下: ImportError: cannot import name 'execute_manager' 修改前后代码对比 修改前的代码 # ...
- 关于Javascript表单验证
//验证字符串非空 var Validator = { VerityLib: { IsNotEmpty: function (input) { if ...
- 通过CSS3,实现元素覆盖效果
在非常多站点中,我们都能够看到这种效果.当用户鼠标进入某一个元素后,下方就会有遮罩层上浮动画,如图: 今天我们就用hover伪类加上css3实现,没有使用不论什么JS <!DOCTYPE htm ...
- Linux命令-文件搜索命令:which
主要用途:查找linu命令,而不是磁盘上的普通文件,并且能看到命令的别名和目录. 区别whereis命令,which在path变量指定的目录中查找命令,并且返回第一个符合的结果.whereis是查找所 ...
- Oracle开发者守则
下面为Oracle大师级语录: Oracle Database developers should follow is to do everything they can in SQL. What t ...
- firefox浏览器批处理插件imacros
http://www.360doc.com/content/14/1012/19/4360822_416372016.shtml javascript部分 var code = "CODE: ...
- Mysql 字符串函数 详解
字符串函数是最常用的一种函数了,如果大家编写过程序的话,不妨回过头去看看自己使用过的函数,可能会惊讶地发现字符串处理的相关函数占已使用过的函数很大一部分.MySQL中字符串函数也是最丰富的一类函数,表 ...
- 【原创】关于$test$plusargs和$value$plusargs的小结【SystemVerilog/Verilog】
[原创]关于$test$plusargs和$value$plusargs的小结 Abtract $test$plusargs和$value$plusargs作为进行Verilog和SystemVeri ...
- UIScrollView 滚动视图—IOS开发
转自:http://blog.csdn.net/iukey/article/details/7319314 UIScrollView 类负责所有基于 UIKit 的滚动操作. 一.创建 CGRect ...