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 ...
随机推荐
- Hadoop2.6.0伪分布式搭建
环境: 1.Ubuntu14.04 首先要在linux系统上新建一个账户,比如就叫做hadoop,用于专门运行hadoop. 2.配置jdk 我是使用的版本是jdk1.8. 解压:创建/usr/jav ...
- Activiti工作流(一)——Activiti Diagram
工作流解决在多个参与者之间按照某种预定义的规则传递文档.信息或任务的过程自动进行,从而实现某个预期的业务目标,或者促使此目标的实现. 使用Eclipse开发,需要安排工作流插件,详情见下面. Name ...
- Flink之状态之checkpointing
1.前言 在Flink中,函数和操作符都可以是有状态的.在处理每个消息或者元素时,有状态的函数都会储存信息,使得状态成为精密操作中关键的组成部分. 为了使状态能够容错,Flink会checkpoint ...
- hdu 2838 Cow Sorting (树状数组)
Cow Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- DataBase -- Customers Who Never Order
Question: Suppose that a website contains two tables, the Customers table and the Orders table. Writ ...
- [洛谷P1747]好奇怪的游戏
题目大意:有两匹马,马可以走"日",也可以像象走"田",求它走到(1,1)的步数. 题解:bfs 卡点:边界判断成了可以走到(0,y)或(x,0) C++ Co ...
- MFC中ON_UPDATE_COMMAND_UI和ON_COMMAND消息区别
原文链接地址:http://www.cnblogs.com/orez88/articles/2217823.html 第一个是你打开这个菜单时,处理这个菜单的状态,比如选中.变灰等等. 第二个是响应 ...
- #define、const、typedef的区别
#define.const.typedef的区别 #define 并不是定义变量, 只是用来做文本替换 例如: #define PI 3.1415926 float angel; angel=30*P ...
- 【BZOJ 2753 滑雪与时间胶囊】
Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 2843 Solved: 993[Submit][Status][Discuss] Descripti ...
- [COGS 2421] [HZOI 2016] 简单的Treap 笛卡尔树
笛卡尔树就是你给两维限制,一维堆R,一维二叉搜索树K,平地拔起一棵Treap,最广范的应用:用LCA求区间最值,建Treap,还有个什么范围top k我表示并不会查都查不到.它最妙最高的地方在于用栈来 ...