1034 - Navigation
Global Positioning System (GPS) is a navigation system based on a set of satellites orbiting approximately 20,000 kilometers above the earth. Each satellite follows a known orbit and transmits a radio signal that encodes the current time. If a GPS-equipped vehicle has a very accurate clock, it can compare its own local time with the time encoded in the signals received from the satellites. Since radio signals propagate at a known rate, the vehicle can compute the distance between its current location and the location of the satellite when the signal was broadcast. By measuring its distance from several satellites in known orbits, a vehicle can compute its position very accurately.
You must write a simple ``autopilot" program based on GPS navigation. To make the problem easier, we state it as a two-dimen sional problem. In other words, you do not need to take into account the curvature of the earth or the altitude of the satellites. Furthermore, the problem uses speeds that are more appropriate for airplanes and sound waves than for satellites and radio waves.
Given a set of signals from moving sources, your program must compute the receiving position on the Cartesian plane. Then, given a destination point on the plane, your program must compute the compass heading required to go from the receiving position to the destination. All compass headings are stated in degrees. Compass heading 0 (North) corresponds to the positive y direction, and compass heading 90 (East) corresponds to the positive x direction, as shown in Figure 1.
Input
The input consists of multiple data sets.
The first line of input in each data set contains an integer N ( 1N10), which is the number of signal sources in the set. This is followed by three floating point numbers: t, x, and y. Here, t denotes the exact local time when all the signals are received, represented in seconds after the reference time (time 0), andx and y represent the coordinates of the destination point on the Cartesian plane. Each of the next N lines contains four floating-point numbers that carry information about one signal source. The first two numbers represent the known position of the signal source on the Cartesian plane at the reference time. The third number represents the direction of travel of the signal source in the form of a compass heading D ( 0D < 360). The fourth number is the time that is encoded in the signal-that is, the time when the signal was transmitted, represented in seconds after the reference time. The magnitudes of all numbers in the input file are less than 10000 and no floating-point number has more than 5 digits after the decimal point.
The last data set is followed by a line containing four zeros.
The unit distance in the coordinate space is one meter. Assume that each signal source is moving over the Cartesian plane at a speed of 100 meters per second and that the broadcast signal propagates at a speed of 350 meters per second. Due to inaccuracies in synchronizing clocks, assume that your distance calculations are accurate only to 0.1 meter. That is, if two points are computed to be within 0.1 meter of each other, you should treat them as the same point. There is also the possibility that a signal may have been corrupted in transmission, so the data received from multiple signals may be inconsistent.
Output
For each trial, print the trial number followed by the compass heading from the receiving location to the destination, in degrees rounded to the nearest integer. Use the labeling as shown in the example output. If the signals do not contain enough information to compute the receiving location (that is, more than one position is consistent with the signals), print ` Inconclusive '. If the signals are inconsistent (that is, no position is consistent with the signals), print ` Inconsistent '. If the receiving location is within 0.1 meter of the destination, print ` Arrived '. If the situation is Inconclusive or Inconsistent, then you do not need to consider the case Arrived.
Figure 2 above corresponds to the first sample input. The locations of the three satellites at time t = 0are A (-100,350), B (350,-100) and C (350,800). The signals received by the GPS unit were transmitted at time t = 1.75, when the satellites were at locations A', B', and C' (however, in general the signals received by the GPS unit might have been transmitted at different times). The signals from the three satellites converge at D at time t = 2.53571, which means D is the location of the receiving GPS unit. From point D, a compass course of 45 degrees leads toward the destination point of (1050, 1050).
Sample Input
3 2.53571 1050.0 1050.0
-100.0 350.0 90.0 1.75
350.0 -100.0 0.0 1.75
350.0 800.0 180.0 1.75
2 2.0 1050.0 1050.0
-100.0 350.0 90.0 1.0
350.0 -100.0 0.0 1.0
0 0 0 0
Sample Output
Trial 1: 45 degrees
Trial 2: Inconclusive
#include<cstdio>
#include<cmath>
double t,x,y,ox[12],oy[12],r[12],px,py,dx,dy,dr,degree,ti,pi,dis,lx,ly,xa,ya,xb,yb;
int n,i,cases,c1,c2; int check(double x,double y)
{
int i;
double dx,dy;
for(i=0;i<n;i++)
{
dx=x-ox[i];
dy=y-oy[i];
dr=sqrt(dx*dx+dy*dy)-r[i];
if(fabs(dr)>0.1)
return 0;
}
return 1;
} int main()
{
pi=acos(-1.0);
while(scanf("%d%lf%lf%lf",&n,&t,&x,&y)&&n)
{
for(i=0;i<n;i++)
{
scanf("%lf%lf%lf%lf",&px,&py,°ree,&ti);
degree=(90-degree)/180*pi;
dis=100*ti;
ox[i]=px+dis*cos(degree);
oy[i]=py+dis*sin(degree);
r[i]=350*(t-ti);
}
printf("Trial %d: ",++cases);
for(i=1;i<n;i++)
{
dx=ox[i]-ox[0];
dy=oy[i]-oy[0];
dr=r[i]-r[0];
if(dx*dx+dy*dy+dr*dr>0.01)
break;
}
if(i>=n)
{
puts("Inconclusive");
continue;
}
dis=sqrt(dx*dx+dy*dy);
if(dis<0.1)
{
puts("Inconsistent");
continue;
}
lx=(dis*dis+r[0]*r[0]-r[i]*r[i])/dis/2;
if(fabs(lx)>r[0]+0.1)
{
puts("Inconsistent");
continue;
}
if(lx>r[0])
lx=r[0];
if(lx<-r[0])
lx=-r[0];
ly=sqrt(r[0]*r[0]-lx*lx);
dx/=dis;
dy/=dis;
xa=ox[0]+dx*lx-dy*ly;
ya=oy[0]+dy*lx+dx*ly;
xb=ox[0]+dx*lx+dy*ly;
yb=oy[0]+dy*lx-dx*ly;
if(sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb))<0.1)
{
xb=1e9;
yb=1e9;
}
c1=check(xa,ya);
c2=check(xb,yb);
if(c1+c2==1)
{
if(c2)
{
xa=xb;
ya=yb;
}
dx=x-xa;
dy=y-ya;
dis=sqrt(dx*dx+dy*dy);
if(dis<0.1)
puts("Arrived");
else
{
if(dy>0)
degree=acos(dx/dis);
else
degree=pi*2-acos(dx/dis);
degree=90-degree/pi*180;
if(degree<0)
degree+=360;
if(degree>360)
degree-=360;
printf("%.0lf degrees\n",degree);
}
}
else
if(c1)
puts("Inconclusive");
else
puts("Inconsistent");
}
return 0;
}
1034 - Navigation的更多相关文章
- arcgis api for js共享干货系列之二自定义Navigation控件样式风格
arcgis api for js默认的Navigation控件样式风格如下图: 这样的风格不能说不好,各有各的爱好,审美观,这里也不是重点,这里的重点是如何自定义一套自己喜欢的样式风格呢:自己自定义 ...
- The Safe Navigation Operator (&.) in Ruby
The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...
- Unity3D 导航网格自动寻路(Navigation Mesh)
NavMesh(导航网格)是3D游戏世界中用于实现动态物体自动寻路的一种技术,将游戏中复杂的结构组织关系简化为带有一定信息的网格,在这些网格的基础上通过一系列的计算来实现自动寻路..导航时,只需要给导 ...
- ABP理论学习之导航(Navigation)
返回总目录 本篇目录 创建菜单 注册导航提供者 展示菜单 每一个web应用在页面之间都有一些要导航的菜单.ABP提供了公用的基础设施来创建菜单并将菜单展示给用户. 创建菜单 一个应用可能由不同的模块组 ...
- Sharepoint学习笔记—ECM系列—文档列表的Metedata Navigation与Key Filter功能的实现
如果一个文档列表中存放了成百上千的文档,想要快速的找到你想要的还真不是件容易的事,Sharepoint提供了Metedata Navigation与Key Filter功能可以帮助我们快速的过滤和定位 ...
- iOS第八课——Navigation Controller和Tab bar Controller
今天我们要学习Navigation Controller和Tab bar Controller. Navigation Controller是iOS编程中比较常用的一种容器,用来管理多个视图控制器. ...
- navigation和tabbar上的文字.图片 自定义
[[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor blackColor] ...
- navigation controller
一.程序框架 1.程序结构
- Xcode6 storyboard new push segue 后的视图控制器没有navigation item bug.
手动切一下 老的push,再切回来,就会出有了,我想是一个bug. Xcode 6 Segue with UINavigationItem up vote0down votefavorite I' ...
随机推荐
- 使用Application_Error捕获站点错误并写日志
Global.ascx页面使用以下方法即可捕获应用层没有try cath的错误 protected void Application_Error(Object sender, EventArgs e) ...
- linux学习笔记<基本知识普及>
linux上分区类型 主分区 : 最多自能有4个 扩展分区 : 最多只能有1个 主分区加扩展分区最多只能有4个 不能写入数据,只能包含逻辑分区 逻辑分区 挂载(安装linux系统时若自定义分区,需注 ...
- 策略模式Strategy(对象行为型)
原文地址:http://blog.csdn.net/hguisu/article/details/75582491.策略模式:定义一系列的算法,把每一个算法封装起来, 并且使它们可相互替换.本模式使得 ...
- 原生js实现的放大镜效果
这是我用原生js写的放大镜效果,与各种各样的框架技术相比,我喜欢使用原生的js,在这里,想和大家一起谈谈原生和框架技术的理解与个人喜好. <!DOCTYPE HTML><html&g ...
- 汇编test和cmp区别
来自http://tunps.com/assembly-test-and-cmp 看过破解教程,都知道test,cmp是比较关键,可是我一直不清楚它们究竟是怎么比较的,最后下决心找了很多资料,和大家一 ...
- 使用iframe调用指定网页的特定位置(显示目标网页某区域的我想要的内容)
使用iframe调用指定网页的特定位置(显示目标网页某区域的我想要的内容) 有些时候我们并不需要显示iframe标签属性src指定的目标网页的所有内容,往往只需要显示某一特定区域.现有两种实现方法提供 ...
- 【转】关于FPGA中建立时间和保持时间的探讨
时钟是整个电路最重要.最特殊的信号,系统内大部分器件的动作都是在时钟的跳变沿上进行, 这就要求时钟信号时延差要非常小, 否则就可能造成时序逻辑状态出错:因而明确FPGA设计中决定系统时钟的因素,尽 ...
- CentOS 6.5 + Nginx 1.8.0 + PHP 5.6(with PHP-FPM) 负载均衡源码安装 之 (一)Nginx安装篇
CentOS 6.5 minimal安装不再赘述 Nginx源码安装 1.安装wget下载程序 yum -y install wget 2.安装编译环境:gcc gcc-c++ automake au ...
- 有意思的数学题:Trapping Rain Water
LeetCode传送门 https://leetcode.com/problems/trapping-rain-water/ 目标:找出积木能容纳的水的“面积”,如图中黑色部分是积木,蓝色为可容纳水的 ...
- COJ 1010 WZJ的数据结构(十) 线段树区间操作
传送门:http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=1001 WZJ的数据结构(十) 难度级别:D: 运行时间限制:3000ms: ...