hdu 1140(三维)
War on Weather
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 494 Accepted Submission(s): 270
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 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.
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.)
-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
3
题解:求出卫星和地球的切线长度,在地球上与卫星的距离不超过切线长度的都能看到.
#include <iostream>
#include <cstdio>
#include <string.h>
#include <math.h>
#include <algorithm>
const double pi = atan(1.0)*;
const double R = /pi; ///地球半径
struct Point{
double x,y,z;
}sate[],person[]; double dis(Point a,Point b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z);
}
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF,n+m){
for(int i=;i<n;i++){
scanf("%lf%lf%lf",&sate[i].x,&sate[i].y,&sate[i].z);
}
for(int i=;i<m;i++){
scanf("%lf%lf%lf",&person[i].x,&person[i].y,&person[i].z);
}
int ans = ;
for(int i=;i<m;i++){
for(int j=;j<n;j++){
Point p = {,,}; ///球心
int L = dis(sate[j],p)-R*R; ///切线长度
if(sqrt(L)>=sqrt(dis(sate[j],person[i]))){
ans++;
break;
}
}
}
printf("%d\n",ans);
}
return ;
}
hdu 1140(三维)的更多相关文章
- HDU 4087 三维上的平移缩放旋转矩阵变化
题目大意: 就是根据它给的程序的要求,不断平移,缩放,旋转三维的点,最后计算出点的位置 这里主要是要列出三种转换方式的齐次矩阵描述 平移translate tx ty tz1 0 0 00 1 0 0 ...
- HDU 3584 三维树状数组
三维树状数组模版.优化不动了. #include <set> #include <map> #include <stack> #include <cmath& ...
- hdu 5839(三维几何)
Special Tetrahedron Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 5965 三维dp 或 递推
题意:= =中文题 思路一:比赛时队友想的...然后我赛后想了一下想了个2维dp,但是在转移的时候,貌似出了点小问题...吧?然后就按照队友的思路又写了一遍. 定义dp[i][j][k],表示第i列, ...
- hdu 1140:War on Weather(计算几何,水题)
War on Weather Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1253 三维数组的图上找最短路
题目大意: 从三维空间的(0,0,0)出发到(a-1,b-1,c-1),每移动一个都要时间加一,计算最短时间 根据六个方向,开个bfs,像spfa那样计算最短路径就行了,但是要1200多ms,也不知道 ...
- hdu 4826 三维dp
dp的问题除了递推过程的设计之外 还有数据结构的选择以及怎样合理的填充数据 这个的填充是个坑..#include<iostream> #include<cstdio> #inc ...
- HDU 3584 Cube (三维 树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3584 Cube Problem Description Given an N*N*N cube A, ...
- hdu 4273 2012长春赛区网络赛 三维凸包中心到最近面距离 ***
新模板 /* HDU 4273 Rescue 给一个三维凸包,求重心到表面的最短距离 模板题:三维凸包+多边形重心+点面距离 */ #include<stdio.h> #include&l ...
随机推荐
- hadoop 2.6.0 伪分布式部署安装遇到的问题
之前读到了一篇关于配置安装hadoop的博文(地址:http://www.powerxing.com/install-hadoop/)能正确安装和运行,但是在网页进行Jobtracker监控时,输入l ...
- php实现base64图片上传方式实例代码
<?php /** * base64图片上传 * @param $base64_img * @return array */ header("content-type:text/htm ...
- div clear清除浮动产生的影响 被受影响的div加上清除浮动后 不会填充前一个div浮动后空出的位置
- 【bzoj2006】[NOI2010]超级钢琴 倍增RMQ+STL-堆
题目描述 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度为Ai,其中A ...
- BZOJ4563 HAOI2016放棋子(高精度)
没看清题还以为是要求数最大匹配数量……注意到任意障碍不在同一行同一列,且恰好有n个障碍,不妨通过交换列使得第i行第i列均有障碍.那么就是个错排了.居然wa了一发简直没救. #include<io ...
- 2017 Multi-University Training Contest - Team 3 Kanade's trio(字典树+组合数学)
题解: 官方题解太简略了orz 具体实现的方式其实有很多 问题就在于确定A[j]以后,如何找符合条件的A[i] 这里其实就是要提前预处理好 我是倒序插入点的,所以要沿着A[k]爬树,找符合的A[i] ...
- sql如何先排序再去重
场景 有一张得分表(score),记录了用户每次的得分,同一个人可能有多个得分. id name score 1 tom 45 2 jack 78 3 tom 34 . . . 需求:找出分数最高的前 ...
- [CF1031E]Triple Flips
题目大意:给你一个长度为$n$的$01$串,一次操作定义为:选取$3$个等距的元素,使其$0$变$1$,$1$变$0$,要求在$\Big\lfloor \dfrac n 3\Big\rfloor+12 ...
- [洛谷P4015]运输问题
题目大意:有m个仓库和n个商店.第i个仓库有 $a_{i}$ 货物,第j个商店需要$b_{j}$个货物.从第i个仓库运送每单位货物到第j个商店的费用为$c_{i,j}$.求出最小费用和最大费用 题 ...
- OSI 七层模型和 TCP/IP 四层模型 及 相关网络协议
简介 OSI 是理论上的模型,也就是一个统一的国际标准,现在的很多网络设备或者是网络协议都不同程度的精简了自己的所谓的模型,那么他们为了自己的通讯兼容都会参考这个OSI模型 TCP/IP 包括: TC ...