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

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
 
刚开始被题目和AC的人吓唬了,感觉很难,,结果就一水题
题意:给出n颗卫星和m个人的三维坐标,问这m个人中有多少人可以被卫星至少一颗卫星覆盖
题解:求出卫星和地球的切线长度,在地球上与卫星的距离不超过切线长度的都能看到.
#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(三维)的更多相关文章

  1. HDU 4087 三维上的平移缩放旋转矩阵变化

    题目大意: 就是根据它给的程序的要求,不断平移,缩放,旋转三维的点,最后计算出点的位置 这里主要是要列出三种转换方式的齐次矩阵描述 平移translate tx ty tz1 0 0 00 1 0 0 ...

  2. HDU 3584 三维树状数组

    三维树状数组模版.优化不动了. #include <set> #include <map> #include <stack> #include <cmath& ...

  3. hdu 5839(三维几何)

    Special Tetrahedron Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  4. HDU 5965 三维dp 或 递推

    题意:= =中文题 思路一:比赛时队友想的...然后我赛后想了一下想了个2维dp,但是在转移的时候,貌似出了点小问题...吧?然后就按照队友的思路又写了一遍. 定义dp[i][j][k],表示第i列, ...

  5. hdu 1140:War on Weather(计算几何,水题)

    War on Weather Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  6. HDU 1253 三维数组的图上找最短路

    题目大意: 从三维空间的(0,0,0)出发到(a-1,b-1,c-1),每移动一个都要时间加一,计算最短时间 根据六个方向,开个bfs,像spfa那样计算最短路径就行了,但是要1200多ms,也不知道 ...

  7. hdu 4826 三维dp

    dp的问题除了递推过程的设计之外 还有数据结构的选择以及怎样合理的填充数据 这个的填充是个坑..#include<iostream> #include<cstdio> #inc ...

  8. HDU 3584 Cube (三维 树状数组)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3584 Cube Problem Description Given an N*N*N cube A,  ...

  9. hdu 4273 2012长春赛区网络赛 三维凸包中心到最近面距离 ***

    新模板 /* HDU 4273 Rescue 给一个三维凸包,求重心到表面的最短距离 模板题:三维凸包+多边形重心+点面距离 */ #include<stdio.h> #include&l ...

随机推荐

  1. Linux建立FTP服务器

    http://blog.chinaunix.net/uid-20541719-id-1931116.html http://www.cnblogs.com/hnrainll/archive/2011/ ...

  2. CodeForces Round #521 (Div.3) D. Cutting Out

    http://codeforces.com/contest/1077/problem/D You are given an array ss consisting of nn integers. Yo ...

  3. 【EasyNetQ】- 自动订阅者

    从v0.7.1.30开始,EasyNetQ简单易用AutoSubscriber.你可以用它来轻松地扫描实现任何接口的类的特定组件IConsume<T>或IConsumeAsync<T ...

  4. HTML5<canvas>标签:使用canvas元素在网页上绘制渐变和图像(2)

    详细解释HTML5 Canvas中渐进填充的参数设置与使用,Canvas中透明度的设置与使用,结合渐进填充与透明度支持,实现图像的Mask效果. 一:渐进填充(Gradient Fill) Canva ...

  5. C#判断字符串是否为数字字符串

    在进行C#编程时候,有的时候我们需要判断一个字符串是否是数字字符串,我们可以通过以下两种方法来实现.[方法一]:使用 try{} catch{} 语句.      我们可以在try语句块中试图将str ...

  6. Luogu3953 NOIP2017逛公园(最短路+拓扑排序+动态规划)

    跑一遍dij根据最短路DAG进行拓扑排序,按拓扑序dp即可.wa了三发感觉非常凉. #include<iostream> #include<cstdio> #include&l ...

  7. POJ 3693 Maximum repetition substring(最多重复次数的子串)

    Maximum repetition substring Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10461   Ac ...

  8. 洛谷 [CQOI2015]选数 解题报告

    [CQOI2015]选数 题目描述 我们知道,从区间\([L,H]\)(\(L\)和\(H\)为整数)中选取\(N\)个整数,总共有\((H-L+1)^N\)种方案. 小\(z\)很好奇这样选出的数的 ...

  9. 停课day2

    感觉今天好颓啊,我才把昨晚那五道题a了,(但我明明一直在学啊,为啥这么慢,难道是我太笨了?) 闲话少叙,先说做法 问题 A: C Looooops 题目描述 对于C的for(i=A ; i!=B ;i ...

  10. NOIP2010 引水入城 贪心+DFS

    我们先把简单的不能搞死,具题意可证:每个蓄水长的管辖区域一定是连续的.证明:既然我们已经能了那么我们就可以说如果这个区间不是连续的那我们取出这个区间中间阻隔开的那一段,那么对于这一整个区间来说水源不可 ...