码迷,mamicode.com
首页 > 其他好文 > 详细

HDU-2073-无限的路

时间:2014-11-11 22:25:36      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   sp   for   代码   bs   amp   ef   

题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=2073

 

题目思路:

把所有点x,y 到0 0点的距离求出来  ,求两点的距离直接相减就可以了

 

代码:

 

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double cha[210][210];

int main(void)
{
int i,j,k,n;
int x1,x2,y1,y2;
double s,ans;
cha[0][0]=0;
cha[0][1]=1;
cha[1][0]=2.414;
ans=2.414;
for(i=2; i<=200; i++)
{
k=i;
cha[0][k]=sqrt((k-1.0)*(k-1)+k*k)+ans;
ans=cha[0][k];
for(j=1; j<=i; j++)
{
ans=ans+sqrt(2.0);
cha[j][--k]=ans;
}
}
while(scanf("%d",&n)==1&&n)
{
while(n--)
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
s=cha[x1][y1]-cha[x2][y2];
if(s<0)
s=-s;
printf("%.3lf\n",s);
}
}
return 0;
}

HDU-2073-无限的路

标签:http   io   ar   sp   for   代码   bs   amp   ef   

原文地址:http://www.cnblogs.com/liudehao/p/4090541.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!