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 ...
随机推荐
- gradle在build之后执行任务
在打包后一般会有copy jar文件的需求. 先在build.gradle文件中定义你的task: task myCopy{ println "some copy code..." ...
- ASP.NET程序中设置相对路径的方法
如图所示,这是个绝对路径. 改为相对路径的方法是:AppDomain.CurrentDomain.BaseDirectory. 如下图所示:
- Delphi 7学习开发控件(续)
继上次我们学习开发一个简单的画线控件后,基本的制作控件步骤已经清楚了,这次我们继续加深学习控件的制作.我们打开Delphi 7创建一个应用程序,拖动LineTo控件到窗体上,仔细看左边的对象设计器,可 ...
- 使用POI操作Excel
首先要下载所需jar包, 官网:http://poi.apache.org ,POI支持office的所有版本 下载完后,打开“poi-bin-3.10.1-20140818”获取操作excel需要的 ...
- Contest Hunter 模拟赛09 A [线段树维护斜率]
题面 传送门 思路 首先看看我们到底要干什么:有$1e6$次询问,遍历$i$,每次要求一个形如$b_i \ast a_j - a_i \ast b_j$的东西的最大值 考虑如果一个$j$的决策在当前的 ...
- # centos7下FFmpeg环境部署记录
# centos7下FFmpeg环境部署记录 随着视频在网站上的应用越来越多,越来越多的网站服务器需要支持视频转码,视频压缩,FFmpeg是目前最好用的网站服务器后台转码程序,应用最多.FFmpeg是 ...
- Cube 找规律
这道题我们经过简单的推测便可得知3个之前特判,四个之后就成为了一般状况,就是我们每侧都是走整个整个的|_|之后零的走|||. 考试的时候包括平时做题,许多正确的感性比理性证明要强得多. #includ ...
- python 一些乱七八糟的东西
import random import os import sys import re class _is: def __init__(self,reg): self.cr=re.compile(r ...
- 两个数组的交集 II [ LeetCode - 350 ]
原题地址:https://leetcode-cn.com/problems/intersection-of-two-arrays-ii/description/ 给定两个数组,写一个方法来计算 ...
- java实现极简的LRU算法
import java.util.LinkedHashMap;import java.util.Map; /** * LRU (Least Recently Used) */public class ...