1549: Navigition Problem

Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Submitted: 400     Solved: 122


Description

Navigation is a field of study that focuses on the process of monitoring and controlling the movement of a craft or vehicle from one place to another. The field of navigation includes four general categories: land navigation, marine navigation, aeronautic navigation, and space navigation. (From Wikipedia)
Recently, slowalker encountered a problem in the project development of Navigition APP. In order to provide users with accurate navigation service , the Navigation APP should re-initiate geographic location after the user walked DIST meters. Well, here comes the problem. Given the Road Information which could be abstracted as N segments in two-dimensional space and the distance DIST, your task is to calculate all the postion where the Navigition APP should re-initiate geographic location.

Input

The input file contains multiple test cases.
For each test case,the first line contains an interger N and a real number DIST. The following N+1 lines describe the road information.
You should proceed to the end of file.

Hint:
1 <= N <= 1000
0 < DIST < 10,000

Output

For each the case, your program will output all the positions where the Navigition APP should re-initiate geographic location. Output “No Such Points.” if there is no such postion.

Sample Input

2 0.50
0.00 0.00
1.00 0.00
1.00 1.00

Sample Output

0.50,0.00
1.00,0.00
1.00,0.50
1.00,1.00
题目意思:
给你很多点,将这些点连成线段,起点和终点不相连
从起点出发,沿着这些折线走,每一次走d距离
问你每走d距离达到的所有点的坐标
(包括起点和终点)
分析:
就是几何计算+模拟,细节多,每沿着折线走d距离,就是输出一下到达该点的坐标
总长度不足d
就按照题目输出字符串
下一步走d距离超过了终点的话
最后只要输出终点
不用输出超出终点的点
 
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<cctype>
#include<stack>
#include<sstream>
#include<list>
#include<assert.h>
#include<bitset>
#include<numeric>
using namespace std;
typedef long long LL;
#define max_v 1005
struct node
{
double x,y;
}p[max_v];
double len[max_v];
double dis(node a,node b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double sum[max_v];
int main()
{
int n;
double d;
while(~scanf("%d %lf",&n,&d))
{
double c=;
sum[]=;
for(int i=;i<=n+;i++)
{
scanf("%lf %lf",&p[i].x,&p[i].y);
if(i>)
{
len[i-]=dis(p[i],p[i-]);
c+=len[i-];
sum[i-]=sum[i-]+len[i-];
}
}
if(c<d)
{
printf("No Such Points.\n");
continue;
}
double now=,k,x,y;
for(int i=;i<=n;)
{
if(now+d<=sum[i])
{
double L=now+d-sum[i-];
double x1=p[i].x;
double y1=p[i].y;
double x2=p[i+].x;
double y2=p[i+].y; if(x1!=x2)
{
k=(y1-y2)/(x1-x2);
if(x2<x1)
{
x=x1-sqrt((L*L)/(k*k+));
y=k*(x-x1)+y1;
}else
{
x=x1+sqrt((L*L)/(k*k+));
y=k*(x-x1)+y1;
}
}else
{
x=x1;
if(y2<y1)
y=y1-L;
else
y=y1+L;
}
printf("%.2lf,%.2lf\n",x,y);
now=now+d;
}else
{
i++;
}
}
}
return ;
}
/*
题目意思:
给你很多点,将这些点连成线段,起点和终点不相连
从起点出发,沿着这些折线走,每一次走d距离
问你每走d距离达到的所有点的坐标
(包括起点和终点) 分析:
就是几何计算+模拟,细节多,每沿着折线走d距离,就是输出一下到达该点的坐标
总长度不足d
就按照题目输出字符串
下一步走d距离超过了终点的话
最后只要输出终点
不用输出超出终点的点 */

1549: Navigition Problem (几何计算+模拟 细节较多)的更多相关文章

  1. csu 1549: Navigition Problem(几何,模拟)

    1549: Navigition Problem Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 305  Solved: 90[Submit][Stat ...

  2. CSUOJ 1549 Navigition Problem

    1549: Navigition Problem Time Limit: 1 Sec  Memory Limit: 256 MBSubmit: 65  Solved: 12 Description N ...

  3. Jack Straws POJ - 1127 (几何计算)

    Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5428   Accepted: 2461 Descr ...

  4. Direct2D 几何计算和几何变幻

    D2D不仅可以绘制,还可以对多个几何图形对象进行空间运算.这功能应该在GIS界比较吃香. 这些计算包括: 合并几何对象,可以设置求交还是求并,CombineWithGeometry 边界,加宽边界,查 ...

  5. 【11.9校内测试】【倒计时1天】【ak欢乐赛】【多项式计算模拟】

    然而AK失败了,就是因为这道摸你题:(最后一篇题解了吧?QAQ) Solution 模拟多项式乘法,其中的运算处理很像高精度,不过第$i$位代表的就是$x^i$前面的系数了. 好像去年的时候就讲了表达 ...

  6. Gym 100646 Problem C: LCR 模拟题

    Problem C: LCR 题目连接: http://codeforces.com/gym/100646/attachments Description LCR is a simple game f ...

  7. Codeforces 793C - Mice problem(几何)

    题目链接:http://codeforces.com/problemset/problem/793/C 题目大意:给你一个捕鼠器坐标,和各个老鼠的的坐标以及相应坐标的移动速度,问你是否存在一个时间点可 ...

  8. [LeetCode] 数学计算模拟类问题:加法,除法和幂,注意越界问题。题 剑指Offer,Pow(x, n) ,Divide Two Integers

    引言 数学计算的模拟类题目,往往是要求实现某种计算(比如两数相除),实现的过程中会有所限定,比如不允许乘法等等. 这类题目首先要注意计算过程中本身的特殊情况.比如求相除,则必须首先反映过来除数不能为0 ...

  9. Codeforces Round #398 (Div. 2) A B C D 模拟 细节 dfs 贪心

    A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. 洛谷P4783 【模板】矩阵求逆(高斯消元)

    题意 题目链接 Sol 首先在原矩阵的右侧放一个单位矩阵 对左侧的矩阵高斯消元 右侧的矩阵即为逆矩阵 // luogu-judger-enable-o2 #include<bits/stdc++ ...

  2. springboot项目的重定向和转发

    下面是idea软件创建的项目目录,这里总结了一下转发与重定向的问题,详解如下. 首先解释一下每个文件夹的作用,如果你是用的是idea创建的springboot项目,会在项目创建的一开始resource ...

  3. IT小鲜肉 Widgets Tree 单选、多选、相关回调函数、获取选中的节点功能

    写一个树控件并没有想象中的那么容易,今天又花了我一个1个多小时,主要为IT小鲜肉 Widgets Tree控件添加了 单选.多选.选择前和选择后两个回调函数.获取选中节点的功能.后面会继续努力完善这个 ...

  4. chrome 浏览器调用 ocx 插件

    原文:http://blog.csdn.net/wangchao1988ok/article/details/45193489 IE 上使用 ocx 插件网上已经有很多资料说明,这里就不重复了,那如何 ...

  5. Pwn with File结构体之利用 vtable 进行 ROP

    前言 本文以 0x00 CTF 2017 的 babyheap 为例介绍下通过修改 vtable 进行 rop 的操作 (:-_- 漏洞分析 首先查看一下程序开启的安全措施 18:07 haclh@u ...

  6. CSS 样式初始化

    去除浏览器对html的附加样式,避免不同浏览器之间的样式差异,给前端开发提供统一的样式基础.附加样式: .clearfix - 清除浮动 .wordsBreak - 允许文本在任意位置的换行 .ell ...

  7. javaEE-EJB学习笔记

    EJB是sun的JavaEE服务器端组件模型,设计目标与核心应用是部署分布式应用程序.简单来说就是把已经编写好的程序(即:类)打包放在服务器上执行.凭借java跨平台的优势,用EJB技术部署的分布式系 ...

  8. SASS 入门

    为什么使用Sass 作为前端(html.javascript.css)的三大马车之一的css,一直以静态语言存在,HTML5火遍大江南北了.javascript由于NODE.JS而成为目前前后端统一开 ...

  9. 6.JXL操作Excel

    一.简介 jxl是一个韩国人写的java操作excel的工具, 在开源世界中,有两套比较有影响的API可 供使用,一个是POI,一个是jExcelAPI.其中功能相对POI比较弱一点.但jExcelA ...

  10. Oracle EBS 配置文件取值

    SELECT op.profile_option_id, tl.profile_option_name, tl.user_profile_option_name, lv.level_id, lv.文件 ...