Tornado

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 196    Accepted Submission(s): 48

Problem Description
Professor Jonathan is a well-known Canadian physicist and meteorologist. People who know him well call him “Wind Chaser”. It is not only because of his outstanding tornado research which is the most influential in the academic community, but also because of his courageous act in collecting real data of tornados. Actually he has been leading his team chasing tornado by cars equipped with advanced instruments hundreds of times.

In summer, tornado often occurs in the place where Professor Jonathan lives. After several years of research, Wind Chaser found many formation rules and moving patterns of tornados. In the satellite image, a tornado is a circle with radius of several meters to several kilometers. And its center moves between two locations in a straight line, back and forth at a fixed speed. After observing a tornado’s movement, Wind Chaser will pick a highway, which is also a straight line, and chase the tornado along the highway at the maximum speed of his car.

The smallest distance between the Wind Chaser and the center of the tornado during the whole wind chasing process, is called “observation distance”. Observation distance is critical for the research activity. If it is too short, Wind Chaser may get killed; and if it is too far, Wind Chaser can’t observe the tornado well. After many times of risk on lives and upset miss, Wind Chaser turns to you, one of his most brilliant students, for help. The only thing he wants to know is the forthcoming wind chasing will be dangerous, successful or just a miss.

 
Input
Input contains multiple test cases. Each test case consists of three lines which are in the following format.

xw1 yw1 xw2 yw2 vw
xt1 yt1 xt2 yt2 vt
dl du

In the first line, (xw1, yw1) means the start position of Wind Chaser; (xw2, yw2) is another position in the highway which Wind Chaser will definitely pass through; and vw is the speed of the car. Wind chaser will drive to the end of the world along that infinite long highway.
In the second line, (xt1, yt1) is the start position of tornado; (xt2, yt2) is the turn-around position and vt is the tornado’s speed. In other words, the tornado’s center moves back and forth between (xt1, yt1) and (xt2, yt2) at speed vt .

The third line shows that if the observation distance is smaller than dl , it will be very dangerous; and if the observation distance is larger than du, it will be a miss; otherwise it will lead to a perfect observation.

All numbers in the input are floating numbers.

-2000000000 <= xw1, yw1, xw2, yw2, xt1, yt1, xt2, yt2 <= 2000000000
1 <= vw, vt <= 20000
0 <= dl, du <= 2000000

Note:
1.  It’s guaranteed that the observation distance won’t be very close to dl or du during the whole wind chasing process. There will be at least 10-5 of difference. 
2.  Wind Chaser and the tornado start to move at the same time from their start position.

 
Output
For each test case output one line contains one word “Dangerous”, “Perfect” or “Miss” which describes the prediction of the observation.
 
Sample Input
0 0 1 0 2
10 -5 12 7 4
1.3 2.7
0 0 1 0 2
10 -5 12 7 1
0.3 0.4
 
Sample Output
Dangerous
Perfect
 
Source
 
Recommend
gaojie   |   We have carefully selected several similar problems for you:  2490 2494 3254 2267 1755 
 

代码:

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
const int MAX= ;
const double esp = 1e-; struct Tnode
{
double x,y;
}w1,w2,t1,t2;
double vw,vt,dl,du;
double getmin(double a , double b)
{
return (a>b)?b:a;
}
//求点积
double dianji(Tnode &a ,Tnode &b ,Tnode &c)
{
return (b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y);
}
//求叉 积
double det(Tnode &a ,Tnode &b ,Tnode &c)
{
return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
//求距离
double dis(Tnode &a,Tnode &b)
{
return sqrt(fabs((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y)));
}
//求点o到线段的最近的距离
double getdistance(Tnode &o,Tnode a ,Tnode b,double dx,double dy)
{
a.x+=dx;
a.y+=dy;
b.x+=dx;
b.y+=dy;
double d =getmin(dis(o,a),dis(o,b));
double di=dis(a,b);
if(di<=esp) return dis(o,a);
if(dianji(a,o,b)>=-esp&&dianji(b,o,a)>=-esp)
return fabs(det(a,b,o))/di;
else
return getmin(dis(o,a),dis(o,b));
}
//求o到以线段ab为起始,(dx,dy)为间距的平行线段的最近距离
double calc(Tnode &o ,Tnode &a ,Tnode &b , double dx, double dy)
{
Tnode a1,b1;
int ll=,rr=MAX;
while(ll<rr)
{
int mid=(ll+rr)/;
double d1=getdistance(o,a,b,dx*mid,dy*mid);
double d2=getdistance(o,a,b,dx*(mid+),dy*(mid+));
if(d1<=d2+esp) rr=mid;
else ll=mid+;
}
return getdistance(o,a,b,dx*ll,dy*ll);
}
void work()
{
Tnode wdr ,tdr,move,a1,b1,a2,b2;
double distance,time,d,d1,d2;
distance=dis(w1,w2);
wdr.x = (w2.x-w1.x)*vw/distance;
wdr.y = (w2.y-w1.y)*vw/distance;
distance = dis(t1,t2);
time = distance/vt;
tdr.x = (t2.x-t1.x)*vt/distance;
tdr.y=(t2.y-t1.y)*vt/distance;
move.x=(-wdr.x+tdr.x)*time;
move.y=(-wdr.y+tdr.y)*time;
//求两个线段簇的第一条线段a1-b1和a2-b2
a1=t1;
b1.x=a1.x+move.x;
b1.y=a1.y+move.y;
move.x=(-wdr.x-tdr.x)*time;
move.y=(-wdr.y-tdr.y)*time;
a2=b1;
b2.x=a2.x+move.x;
b2.y=a2.y+move.y;
//分别求点w1到两个线段簇的最近距离d1和d3
d1=calc(w1,a1,b1,b2.x-a1.x,b2.y-a1.y);
d2=calc(w1,a2,b2,b2.x-a1.x,b2.y-a1.y);
//判断结果
d=getmin(d1,d2);
if(d+esp<d1) printf("Dangerous\n");
else if(d-esp>du) printf("Miss\n");
else printf("Perfect\n");
}
int main()
{
while(scanf("%lf",&w1.x)!=EOF)
{
scanf("%lf%lf%lf%lf",&w1.y,&w2.x,&w2.y,&vw);
scanf("%lf%lf%lf%lf%lf",&t1.x,&t1.y,&t2.x,&t2.y,&vt);
scanf("%lf%lf",&dl,&du);
work();
}
return ;
}

hdu------2488Tornado(几何)的更多相关文章

  1. hdu 5430(几何)

    题意:求光在圆内反射n次后第一次返回原点的方案数 如果k和n-1可约分,则表明是循环多次反射方案才返回原点. #include <iostream> #include <cstrin ...

  2. hdu 1577 WisKey的眼神 (数学几何)

    WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  3. POJ 3831 &amp; HDU 3264 Open-air shopping malls(几何)

    题目链接: POJ:id=3831" target="_blank">http://poj.org/problem?id=3831 HDU:http://acm.h ...

  4. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  5. HDU 1432 Lining Up(几何)

    http://acm.hdu.edu.cn/showproblem.php?pid=1432 题目大意: 2维平面上给定n个点,求一条直线能够穿过点数最多是多少. 解题思路: 因为题目给定的n(1~7 ...

  6. HDU 1392 Surround the Trees(几何 凸包模板)

    http://acm.hdu.edu.cn/showproblem.php?pid=1392 题目大意: 二维平面给定n个点,用一条最短的绳子将所有的点都围在里面,求绳子的长度. 解题思路: 凸包的模 ...

  7. hdu 5839(三维几何)

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

  8. hdu 1115 Lifting the Stone (数学几何)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. hdu 1086 You can Solve a Geometry Problem too (几何)

    You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/3 ...

  10. HDU 5128.The E-pang Palace-计算几何

    The E-pang Palace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Othe ...

随机推荐

  1. 关于header('location:url')的一些说明,php缓冲区

    网上搜索header('location:url')的用法,得到如下三个结论: 1. location和“:”号间不能有空格,否则会出错. 2. 在用header前不能有任何的输出. 3. heade ...

  2. linux终端下为什么用命令打开软件后,要关闭软件才能继续下一条命令?

    用终端打开chromium浏览器(命令:chromium-browser)的时候发现打开浏览器之后无法继续在终端输入命令,只能关闭浏览器或者在终端按下Ctrl+c,此时系统将退出浏览器并可以继续在终端 ...

  3. Web开发, 跳转时出现java.lang.ClassNotFoundException

    发生这种状况一般都是由于类找不到,要么是web.xml没有配对位置,要么是类没有放好

  4. 图解SQL 2008数据库复制

    为了达到数据及时备份,一般采用完整备份+差异备份即可,或者再加上日志备份,本文介绍使用数据库复制技术同步数据: PS:文章以图片为主,图片更能直观的看出操作步骤和配置方法! 1.首先创建一个测试的数据 ...

  5. JS——ajax login test

    1.新建一个webproject,我用的是myeclipse10,建立如下的LoginServlet.java文件 2.编写java文件 import java.io.IOException; imp ...

  6. Android——例子:屏幕切换

    效果图如下:                          Xml文件代码: <?xml version="1.0" encoding="utf-8" ...

  7. NoSQL聚合数据模型

    NoSQL聚合数据模型 特点 聚合数据模型的特点就是把经常访问的数据放在一起(聚合在一块): 这样带来的好处很明显,对于某个查询请求,能够在与数据库一次交互中将所有数据都取出来: 当然,以这种方式存储 ...

  8. python中self,cls

    cls主要用在类方法定义,而self则是实例方法. self, cls 不是关键字,完全可以使用自己写的任意变量代替实现一样的效果. 普通的实例方法,第一个参数需要是self,它表示一个具体的实例本身 ...

  9. uva 10692 Huge Mods 超大数取模

    vjudge上题目链接:Huge Mods 附上截图: 题意不难理解,因为指数的范围太大,所以我就想是不是需要用求幂大法: AB % C = AB % phi(C) + phi(C) % C ( B ...

  10. 转载:最大子段和问题(Maximum Interval Sum)

    一.问题描述         给定长度为n的整数序列,a[1...n], 求[1,n]某个子区间[i , j]使得a[i]+…+a[j]和最大.或者求出最大的这个和.       例如(-2,11,- ...