博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lightoj1433——Minimum Arc Distance (求弧长)
阅读量:2343 次
发布时间:2019-05-10

本文共 1807 字,大约阅读时间需要 6 分钟。

You all probably know how to calculate the distance between two points in two dimensional cartesian plane. But in this problem you have to find the minimum arc distance between two points and they are on a circle centered at another point.

You will be given the co-ordinates of the points A and B and co-ordinate of the center O. You just have to calculate the minimum arc distance between A and B. In the picture, you have to calculate the length of arc ACB. You can assume that A and B will always be on the circle centered at O.

这里写图片描述

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing six integers Ox, Oy, Ax, Ay, Bx, By where (Ox, Oy) indicates the co-ordinate of O, (Ax, Ay) denote the co-ordinate of A and (Bx, By) denote the co-ordinate of B. All the integers will lie in the range [1, 10000].

Output

For each case, print the case number and the minimum arc distance. Errors less than 10-3 will be ignored.

Sample Input

5

5711 3044 477 2186 3257 7746

3233 31 3336 1489 1775 134

453 4480 1137 6678 2395 5716

8757 2995 4807 8660 2294 5429

4439 4272 1366 8741 6820 9145

Output for Sample Input

Case 1: 6641.81699183

Case 2: 2295.92880

Case 3: 1616.690325

Case 4: 4155.64159340

Case 5: 5732.01250253

弧长公式为圆心角弧度*半径

#include
#include
#include
#include
using namespace std;int main(){ int t,tt=0; scanf("%d",&t); while(t--) { double ox,oy,x1,y1,x2,y2; scanf("%lf%lf%lf%lf%lf%lf",&ox,&oy,&x1,&y1,&x2,&y2); printf("Case %d: ",++tt); double l1,l2; l1=sqrt((ox-x1)*(ox-x1)+(oy-y1)*(oy-y1)); l2=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); l2=(double)l2/2; double a=asin(l2/l1); a=a*2.0; printf("%.10lf\n",a*l1); } return 0;}

转载地址:http://spcvb.baihongyu.com/

你可能感兴趣的文章
UML总结(对九种图的认识和如何使用Rational Rose 画图)
查看>>
Java中使用HttpRequest获取用户真实IP地址端口
查看>>
easyUI下拉列表点击事件的使用
查看>>
js遍历map
查看>>
单例模式
查看>>
JDBC连接数据库核心代码
查看>>
java生成随机汉字
查看>>
Java反射的基本应用
查看>>
HTML5常用标签
查看>>
where 1=1影响效率以及having和where的区别
查看>>
资源链接
查看>>
注册中心Eureka页面添加用户认证
查看>>
spring源码
查看>>
上传jar包到nexus私服
查看>>
lambda和抽象类
查看>>
idea自定义文档注释模板
查看>>
Enterprise Architect 生成项目类图
查看>>
idea导出配置
查看>>
JVM学习资料收集
查看>>
Codility经典算法题之九:MissingInteger
查看>>