uva 10553 Treasure Map (指南针偏差航海寻宝）

#include <bits/stdc++.h>
#include <iostream>

using namespace std;
const double eps = acos(-1.0);
int  n;
double num;
string str[32] = {"N", "NbE", "NNE", "NEbN", "NE", "NEbE", "ENE", "EbN", "E", "EbS", "ESE", "SEbE", "SE", "SEbS", "SSE",
"SbE", "S", "SbW", "SSW", "SWbS", "SW", "SWbW", "WSW", "WbS", "W", "WbN", "WNW", "NWbW", "NW", "NWbN", "NNW", "NbW"
};
struct Point
{
double x;double y;
Point(){};   //不加这一句，有的编译器会报错，no matching function for call to ...
Point(const double xx,const double yy)
{
x = xx; y = yy;
}
};
{
double x;
double y;
{
x = xx; y = yy;
}
};
map<string,double> direction;
void init()
{
for(int i = 0; i < 32; i++)
{
direction[str[i]] = eps*i/16;
}
}
{
string str0;
double num0;
for(int i = 0; i< n; i++)
{
cin >> str0 >> num0;

}
cin >> num;
num = num *eps /180;
}
double dis(Point p1,Point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y));
}
double dot(Point p0,Point p1,Point p2){  //p0p1点乘 p0p2;
return (p1.x-p0.x)*(p2.x-p0.x)+(p1.y-p0.y)*(p2.y-p0.y);
}

struct line{
Point a,b;
line(const Point a0,const Point b0){a=a0;b=b0;}
double getdis(Point p){//点到线段的最小距离
if(dot(a,p,b)<0 || dot(b,p,a)<0) return min(dis(p,a),dis(p,b));
else{
double a0,b0,c0;
a0=a.y-b.y;
b0=b.x-a.x;
c0=a.x*b.y-b.x*a.y;
return fabs(a0*p.x+b0*p.y+c0)/sqrt(a0*a0+b0*b0);
}
}
};
void computing()
{
Point d(0,0),t(0,0),pre;
for(int i=0;i<n;i++){
}
double ans=dis(d,t);
for(int i=0;i<n;i++){
pre=t;
line l(pre,t);
ans=min(ans,l.getdis(d));
}
printf("%.2lf\n",ans);
}
int main()
{

init();
while(scanf("%d",&n)&&n)
{
computing();
}
return 0;
}


uva 10553 Treasure Map

2016-05-25 16:53:04

uva 10553 Treasure Map (藏宝图)

2013-05-18 22:05:18

【Android开发VR实战】三.开发一个寻宝类VR游戏TreasureHunt

2016-12-30 09:31:16

2016-04-30 23:47:26

ZOJ-3209-Treasure Map【6th浙江省赛】【DLX精确覆盖】【模板题】

2016-02-22 17:42:37

2017-2018 ACM-ICPC Southeast Regional Contest (Div. 1) J.Treasure Map dp

2017-12-11 22:43:51

CF - 817A. Treasure Hunt - 思维

2017-06-17 20:31:49

古人航海怎么定位？带你领略古人的智慧

2016-11-24 17:59:46

2017年上海金马五校程序设计竞赛：Problem K : Treasure Map

2017-06-03 20:21:35

寻宝路线

2018-04-12 15:22:15