View Code of Problem 106

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
	double x1, y1, x2, y2, r;
	while(~scanf("%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &r)){
		double j = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
		if(x1==x2&&y2==y1){
			printf("重合\n");
		}else if(j==2*r){
			printf("相切\n");
		}else if(j>2*r){
			printf("相离\n");
		}else{
			printf("相交 ");
			double z, a;
			z = acos(j/(2*r));
			a = 2*r*r*z-j*r*sin(z);
			printf("%.2lf\n", a);
		}
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 106