hnu_13268 Navigition Problem
来源:互联网 发布:音视频编辑软件 编辑:程序博客网 时间:2024/06/05 19:41
#include<iostream>#include<cstdio>#include<cmath>using namespace std;double calc(double x1,double y1,double x2,double y2) //计算两点间的距离{ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}int main(){ double x,y,x1,y1; int n; double dist; while(~scanf("%d%lf",&n,&dist)) { scanf("%lf%lf",&x,&y); double sum=0; //上一个输出的点到该点的距离 int flag=0; for(int i=1;i<=n;i++) { scanf("%lf%lf",&x1,&y1); double ans=calc(x,y,x1,y1); sum+=ans; if(sum>=dist) //浮点数相等不应该直接这样表示,运气好A了。。 { printf("%.2f,%.2f\n",x+(x1-x)*(dist-(sum-ans))/ans,y+(y1-y)*(dist-(sum-ans))/ans); flag=1; //只要输出过一次,就存在这样的点 double cost=dist-(sum-ans); sum-=dist; while(sum>=dist) //两点间距离比较长,可以输出多个点 { printf("%.2f,%.2f\n",x+(x1-x)*(cost+dist)/ans,y+(y1-y)*(cost+dist)/ans); sum-=dist; cost+=dist; } x=x1; y=y1; //(x,y),(x1,y1) 滚动使用 } else { x=x1; y=y1; } } if(!flag) printf("No Such Points.\n"); } return 0;}
0 0
- hnu_13268 Navigition Problem
- CSU1549-Navigition Problem-几何简单题
- UE4中借用Navigition组件获得PathPoint,来达到寻路效果
- problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- 15
- iOS开发-UIApplication和delegate & iOS程序的启动原理
- sublime text 3更改已有的build system(debian jessie)
- 【转自mos文章】检查selinux状态的方法
- ARC的基本使用
- hnu_13268 Navigition Problem
- 【HDU】3572 Task Schedule (最大流 ISAP算法)
- Redis 管道pipeline
- HTML5-桌面式web应用-数据存储
- Block(一)---Blocks概要
- GCD
- 神奇的37%法则
- win8.1安装马上6,连不上
- hdu 2815 Mod Tree(高次同余方程)