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. java正则表达式2 -- 匹配、切割、查找

    import java.util.Arrays; /* 正则表达式的作用: 1 匹配 2 切割 3 替换 * */ public class Demo1 { public static void ma ...

  2. poi解析excel出现格式不正确

    后缀为xlsx的excel做系统导入时出现bug: Strict OOXML isn't currently supported, please see bug #57699 为了同时兼容03.07及 ...

  3. HDU 2175 汉诺塔IX

    http://acm.hdu.edu.cn/showproblem.php?pid=2175 Problem Description 1,2,...,n表示n个盘子.数字大盘子就大.n个盘子放在第1根 ...

  4. elmentUI组件怎么绑定原生事件

    el-input为例: <el-input id="user-input" type="textarea" placeholder="请换行输入 ...

  5. 【bzoj2124】等差子序列 STL-bitset

    题目描述 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…<pLen<=N (Len>=3),使得Ap1,Ap2,A ...

  6. hdu 1787 GCD Again (欧拉函数)

    GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. 【题解】Bzoj2560串珠子

    挺强的……容斥+状压DP.首先想到如果可以求出f[k],f[k]代表联通状态为k的情况下的合法方案数,则f[k] = g[k] - 非法方案数.g[k]为总的方案数,这是容易求得的.那么非法方案数我们 ...

  8. 2018牛客多校第一场 A.Monotonic Matrix

    题意: 给一个n*m的矩阵赋值(0,1,2).使得每个数都不小于它左面和上面的数. 题解: 构建0和1的轮廓线.对于单独的轮廓线,共需要往上走n步,往右走m步.有C(n+m,n)种方式. 两个轮廓线的 ...

  9. [Leetcode] n queens ii n皇后问题

    Follow up for N-Queens problem. Now, instead outputting board configurations, return the total numbe ...

  10. idea设置文件的编码格式

    在打开某些类时会发现注释是乱码的,该如何解决idea的文件乱码呢?这就需要设置这个文件的合适编码格式: idea设置文件编码的两种方式分别如下: 第一种方式点击idea的右下角的图标如下图所示: 第二 ...