CSUOJ 1549 Navigition Problem
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的更多相关文章
- 1549: Navigition Problem (几何计算+模拟 细节较多)
1549: Navigition Problem Submit Page Summary Time Limit: 1 Sec Memory Limit: 256 Mb Su ...
- csu 1549: Navigition Problem(几何,模拟)
1549: Navigition Problem Time Limit: 1 Sec Memory Limit: 256 MBSubmit: 305 Solved: 90[Submit][Stat ...
- Contest2071 - 湖南多校对抗赛(2015.03.28)
Contest2071 - 湖南多校对抗赛(2015.03.28) 本次比赛试题由湖南大学ACM校队原创 http://acm.csu.edu.cn/OnlineJudge/contest.php?c ...
- CSUOJ 1170 A sample problem
J: A Simple Problem Submit Page Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 87 S ...
- csuoj 1511: 残缺的棋盘
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 1511: 残缺的棋盘 时间限制: 1 Sec 内存限制: 128 MB 题目描述 输入 ...
- CSU-1170 A Simple Problem
题目链接 http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=1170 题目 Description 在一个由N个整数组成的数列中,最 ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- 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 ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
随机推荐
- server问题排查经常使用命令
1.top 查看系统负载情况,load average CPU使用情况,按1查看每一个CPU的使用情况 shift+h 查看每一个线程的情况 2.free -m 按兆为单位输出内存的已用,未用. ...
- poj 1094 / zoj 1060 Sorting It All Out
Sorting It All Out Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 26876 Accepted: 92 ...
- sicily 1003. hash
Description 请用HASH链式法来解决冲突,且规定链表在链表头插入新元素. 规定HASH函数为:h(x) = x % 11,即哈希数组下标为0-10. 给定两种操作: I 操作,插入一个新的 ...
- java9新特性-9-语法改进:try语句
1. 使用举例 在java8 之前,我们习惯于这样处理资源的关闭: java 8 中,可以实现资源的自动关闭,但是要求执行后必须关闭的所有资源必须在try子句中初始化,否则编译不通过.如下例所 ...
- vue打包后显示空白正确处理方法
vue打包后显示空白正确处理方法是 1.找到配置文件(js与css加载不上) 修改 这样打包处理可以打开但是页面样式会找不到 2.修改(针对css中的图片加载不上) 找到对应的位置加上publicPa ...
- CSS 制作 圆角TAB选项卡下拉效果(顺便学习CSS伪元素
CSS伪元素: 伪元素如果没有设置“content”属性,伪元素是无用的. 使用伪元素插入的内容在页面的源码里是不可见的,只能在css里可见 插入的元素在默认情况下是内联元素(或者,在html5中,在 ...
- NodeJS学习笔记 (21)事件机制-events(ok)
模块概览 events模块是node的核心模块之一,几乎所有常用的node模块都继承了events模块,比如http.fs等. 模块本身非常简单,API虽然也不少,但常用的就那么几个,这里举几个简单例 ...
- 超链接:a标签
a标签的功能:实现跳转功能 a标签的重要属性:href,target href的值为跳转目标的地址,如果是跳转页面的话,需要这个页面的超链接. target的值有四个:_blank._self._pa ...
- Kubernetes本地私有仓库配置
实验环境 master 10.6.191.181 node1 10.6.191.182 node2 10.6.191.183 本地私有仓库 10.6.191.184 一.安装本地私有仓库 1.安装do ...
- python中的装饰器decorator
python中的装饰器 装饰器是为了解决以下描述的问题而产生的方法 我们在已有的函数代码的基础上,想要动态的为这个函数增加功能而又不改变原函数的代码 例如有三个函数: def f1(x): retur ...