Gym - 101170K[计算几何]

题目链接:https://vjudge.net/problem/Gym-101170K

 

解题思路:

由于题目前提,所以每个夹角肯定可以夹住一个圆,然后再判断是内角还是外角。还有圆不能越出边框。

 

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mx = 2e3 + 10;
int n,m;
struct node
{
	double x,y;
	node operator - (node A)const{ return node{x-A.x,y-A.y}; }
	node operator + (node A)const{ return node{x+A.x,y+A.y}; }
	node operator * (double d)const{ return node{x*d,y*d}; }
	node operator / (double d)const{ return node{x/d,y/d}; }	
	double operator * (node A)const{ return x*A.x + y*A.y;	} 
}s[mx],ans[mx];
double dist(node A){ return sqrt(A.x*A.x+A.y*A.y); }
node getDot(double c1,node A,node B)
{
	A = A / dist(A);
	B = B / dist(B);
	node F = (A+B)/2.0;
	F = F / dist(F);
	return F*c1;
}
double cross(node p1,node p2){ return p1.x*p2.y - p2.x*p1.y; }
double segdist(node w,node A,node B)//点到线段距离 
{
	if((w-A)*(B-A)>=0&&(w-B)*(A-B)>=0) return fabs(cross(w-A,B-A))/dist(B-A);
	return min(dist(w-A),dist(w-B));
}
bool check(node A){
	for(int i=0;i<n;i++)
	if(segdist(A,s[i],s[(i+1)%n])<4000) return 1;
	return 0;
}
int main(){
	scanf("%d",&n); 
	for(int i=0;i<n;i++){
		scanf("%lf%lf",&s[i].x,&s[i].y);
	}
	for(int i=0;i<n;i++){
		int l = i,mid = (i+1)%n,r = (i+2)%n;
		node A = s[l] - s[mid];
		node B = s[r] - s[mid];
		if(cross(A,B)<0) continue; 
		double angle = A*B / (dist(A)*dist(B));
		angle = acos(angle)/2;
		ans[m++] = getDot(4000.1/sin(angle),A,B)+s[mid];
		if(check(ans[m-1])) m--;
	}
	for(int i=0;i<m;i++){
		for(int j=i+1;j<m;j++){
			if(dist(ans[j]-ans[i])>=8000){
				printf("%.6lf %.6lf\n",ans[i].x,ans[i].y);
				printf("%.6lf %.6lf\n",ans[j].x,ans[j].y);
				return 0;
			}
		}
	}
	puts("impossible");
    return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值