1549: Navigition Problem

Time Limit: 1 Sec  Memory Limit: 256 MB
Submit: 65  Solved: 12

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

HINT

 

Source

解题:此题太JB难读了,就是每次走了dist距离 然后输出此时的坐标位置,记得一定要走够dist的距离才输出坐标,还有坐标中间有逗号。。

 #include <bits/stdc++.h>
using namespace std;
const int maxn = ;
int n;
double R;
struct Point {
double x,y;
} p[maxn];
double getDis(const Point &a,const Point &b) {
double tmp = (a.x - b.x)*(a.x - b.x);
tmp += (a.y - b.y)*(a.y - b.y);
return sqrt(tmp);
}
vector<Point>ans;
int main() {
while(~scanf("%d %lf",&n,&R)) {
for(int i = ; i <= n; ++i)
scanf("%lf %lf",&p[i].x,&p[i].y);
int low = ,high = n;
Point now = p[low++];
ans.clear();
double hg = ;
while(low <= high) {
double ds = getDis(now,p[low]);
if((ds - R + hg) > 1e-) {
now.x += (p[low].x - now.x)/ds*(R-hg);
now.y += (p[low].y - now.y)/ds*(R-hg);
hg += R - hg;
}else{
hg += ds;
now = p[low++];
}
if(fabs(hg - R) < 1e-) {
ans.push_back(now);
hg = 0.0;
}
}
if(ans.size()) {
for(int i = ; i < ans.size(); ++i)
printf("%.2f,%.2f\n",ans[i].x,ans[i].y);
} else puts("No Such Points.");
}
return ;
}

CSUOJ 1549 Navigition Problem的更多相关文章

  1. 1549: Navigition Problem (几何计算+模拟 细节较多)

    1549: Navigition Problem Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Su ...

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

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

  3. Contest2071 - 湖南多校对抗赛(2015.03.28)

    Contest2071 - 湖南多校对抗赛(2015.03.28) 本次比赛试题由湖南大学ACM校队原创 http://acm.csu.edu.cn/OnlineJudge/contest.php?c ...

  4. CSUOJ 1170 A sample problem

    J: A Simple Problem Submit Page   Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 87     S ...

  5. csuoj 1511: 残缺的棋盘

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 1511: 残缺的棋盘 时间限制: 1 Sec  内存限制: 128 MB 题目描述 输入 ...

  6. CSU-1170 A Simple Problem

    题目链接 http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=1170 题目 Description ​ 在一个由N个整数组成的数列中,最 ...

  7. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  8. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  9. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

随机推荐

  1. PAT(B) 101-111-1-2014-03-01

    1.个位数统计: #include<stdio.h> #include<iostream> #include<string.h> #include<set&g ...

  2. 小米净水器与小区过滤价格水对照.xls

    总结:要是一天用水量为7升下面.还是用小区的过滤水为好,合算. 假设过滤水需求量大,可能小米的净水器比較好.当然,小区的要天天去接.要求风雨无阻的. 这点小米的随用随接就更好. 注意一点,小米的还要用 ...

  3. ThinkPHP5中find()和select()区别

    ThinkPHP5中find()和select()区别 读取数据是指读取数据表中的一行数据(或者关联数据),主要通过find方法完成,例如: 1 2 3 4 $User = M("User& ...

  4. matlab subplot(figure)如何设置使得图像最终显示出来不一样大小

    1. 问题描述 figure subplot(1, 2, 1), imshow(A) subplot(1, 2, 2), imshow(B) 无论 A 和 B 的 size 是否一致,最终显示出来的 ...

  5. Automation testing tool comparison - UFT & CodedUITest

    Ease of Use - Recording and Playback Functionality UFT provides 4 models to record a new test. Norma ...

  6. MyBatis+mysql查询和添加数据

    项目结构: Menu package com.mstf.dao; import java.util.Scanner; import org.apache.ibatis.session.SqlSessi ...

  7. DefaultView 的作用(对DataSet查询出的来数据进行排序)

    DefaultView 的作用 收藏    一直以来在对数据进行排序, 条件查询都是直接重复构建SQL来进行, 在查询次数和数据量不多的情况下倒没觉得什么, 但慢慢得, 当程序需要对大量数据椐不同条件 ...

  8. 51Nod 最长的循环节(打表预处理)

    正整数k的倒数1/k,写为10进制的小数如果为无限循环小数,则存在一个循环节,求<=n的数中,倒数循环节长度最长的那个数,假如存在多个最优的答案,输出所有答案中最大的那个数.     1/6= ...

  9. exsi从磁盘中加载虚拟机

    e

  10. The Future Of ReactiveCocoa by Justin Spahr-Summers

    https://www.bilibili.com/video/av9783052?from=search&seid=14165903430339282774