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 ...
随机推荐
- 支持并发的httpclient(基于tcp连接池以及netty)
闲来无事,将曾经自己写的一个库放出来吧. . 有的时候会有这样子的需求: (1)serverA通过HTTP协议来訪问serverB (2)serverA可能会并发的像B发送非常多HTTP请求 类似于上 ...
- JDK的安装及配置环境变量
开发java程序的必备工具:JDK,全名是Java Development Kit, 是Java语言的软件开发工具包. 第一步:下载安装包 从Oracle官网可以选择自己所需的版本下载,(附Oracl ...
- thinkphp 中模型究竟是什么用?
thinkphp 中模型究竟是什么用? 问题 似乎所有的操作都能在控制器中就能完成,模型除了几种验证之外,究竟是干什么用的,这个问题一直没理解透 解答 解答一 要明白这个问题,必须了解 MVC 历史. ...
- django 笔记8 url模板 自定义函数 simple_tag
感谢alex老师~ 知识点: URL - 两个没见 url>路由系统> 函数或类 > 返回字符串 Form表单提交: 提交 >url>函数或类中的方法 -.. HttpR ...
- Apache Bench测试
- 压力测试神器 Siege - Locust Web测压工具python开源 - 介绍: ab是apachebench命令的缩写. ab的原理:ab命令会创建多个并发访问线程,模拟多个访问者同时对某 ...
- bzoj3252: 攻略 优先队列 并查集 贪心
考场上自己yy出来的做法..... Code: #include<cstdio> #include<algorithm> #include<queue> #incl ...
- 【Git 二】Windows|Mac 安装 Git
Windows 或 Mac 上安装 Git 相对于 Linux 上安装来说步骤是简便一些的.Linux 安装步骤见:[Git 一]Linux安装Git 一.Windows 安装 Git 直接下载对应 ...
- AtCoderBeginner091-C 2D Plane 2N Points 模拟问题
题目链接:https://abc091.contest.atcoder.jp/tasks/arc092_a 题意 On a two-dimensional plane, there are N red ...
- python etree.HTML
1.编码问题(编码参数 parser): resp_html = etree.HTML(res,parser=etree.HTMLParser(encoding='gbk')) 2.大小写问题(大写转 ...
- Python 上下文(Context)学习笔记
前言 最早接触到with语句的时候,是初学python,对文件进行读写的时候,当时文件读写一般都是用open()函数来对文件进行读写,为了防止读写的过程中出现错误,也为了让代码更加的pythonic, ...