题目链接:点这里
题意:给一个圆的圆心和圆上两点的坐标,求圆上两点间的弧长。
思路:弧长公式:l = r*A 。
AC代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define ll long long
using namespace std;
const double PI = acos(-1.0);
struct point {
double x,y;
// point(double x = 0,double y = 0){}
};
double dis(point a,point b) {
return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y);
}
int main(){
int t; scanf("%d",&t);
for(int cas = 1; cas<=t; cas++) {
point a,b,o;
scanf("%lf%lf%lf%lf%lf%lf",&o.x,&o.y,&a.x,&a.y,&b.x,&b.y);
double A = dis(o,a);
double B = dis(a,b);
double t = acos((A+A-B)/(2*A));
if((A-0.0) <= 1e-8) {
printf("Case %d: 0.0000000\n",cas); continue;
}
printf("Case %d: %.9lf\n",cas,t*sqrt(A));
}
return 0;
}
/*
5
1 1 1 1 1 1
10 10 9 10 11 10
10000 10000 9000 10000 10000 9000
10000 10000 10000 9000 9000 10000
1 1 101 1 1 101
Output
Case 1: 0.00000000
Case 2: 3.14159265
Case 3: 1570.79632679
Case 4: 1570.79632679
Case 5: 157.07963268
*/