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 ...
随机推荐
- Canvas中的非零围绕规则原理
非零围绕规则:对于路径中指定范围区域,从该区域内部画一条足够长的线段.使此线段的全然落在路径范围之外. 非零围绕规则计数器:然后,将计数器初始化为0,每当这个线段与路径上的直线或曲线相交时,就改变计数 ...
- Codeforces 559B Equivalent Strings 等价串
题意:给定两个等长串a,b.推断是否等价.等价的含义为:若长度为奇数,则必须是同样串.若长度是偶数,则将两串都均分成长度为原串一半的两个子串al,ar和bl,br,当中al和bl等价且ar和br等价, ...
- ThinkPHP5中find()和select()区别
ThinkPHP5中find()和select()区别 读取数据是指读取数据表中的一行数据(或者关联数据),主要通过find方法完成,例如: 1 2 3 4 $User = M("User& ...
- Java类和对象5
写一个Java应用程序,该应用程序包括2个类:Print类和主类E.Print类里有一个方法output()功能是输出100 ~ 999之间的所有水仙花数(各位数字的立方和等于这个三位数本身,如: 3 ...
- ajax无刷新翻页后,jquery失效问题的解决
例如 $(".entry-title a").click(function () { 只对第一页有效, 修改为 $(document).on('click', ".e ...
- 1893. [国家集训队2011]等差子序列(bitset)
★★ 输入文件:nt2011_sequence.in 输出文件:nt2011_sequence.out 简单对比时间限制:0.3 s 内存限制:512 MB [试题来源] 2011中国 ...
- UVa 208 Firetruck【回溯】
题意:给出一个n个节点的无向图,以及某个节点k,按照字典序从小到大输出从节点1到节点k的所有路径 看的题解 http://blog.csdn.net/hcbbt/article/details/975 ...
- Class.forName()用法详解 【转】
来源 http://blog.csdn.net/kaiwii/article/details/7405761 主要功能 Class.forName(xxx.xx.xx)返回的是一个类 Class.f ...
- [POI2011]MET-Meteors(整体二分+树状数组)
题意 给定一个环,每个节点有一个所属国家,k次事件,每次对[l,r]区间上的每个点点权加上一个值,求每个国家最早多少次操作之后所有点的点权和能达到一个值 题解 一个一个国家算会T.这题要用整体二分.我 ...
- Java基础学习总结(29)——浅谈Java中的Set、List、Map的区别
就学习经验,浅谈Java中的Set,List,Map的区别,对JAVA的集合的理解是想对于数组: 数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型),JAVA集合可以存储和操 ...