HDU 3264 오픈 에 어 쇼핑 몰 [교차 원 면적 + 2 분 검색] [계산 기하학]
Open-air shopping malls
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2314 Accepted Submission(s): 859
Problem Description The city of M is a famous shopping city and its open-air shopping malls are extremely attractive. During the tourist seasons, thousands of people crowded into these shopping malls and enjoy the vary-different shopping.
Unfortunately, the climate has changed little by little and now rainy days seriously affected the operation of open-air shopping malls—it’s obvious that nobody will have a good mood when shopping in the rain. In order to change this situation, the manager of these open-air shopping malls would like to build a giant umbrella to solve this problem.
These shopping malls can be considered as different circles. It is guaranteed that these circles will not intersect with each other and no circles will be contained in another one. The giant umbrella is also a circle. Due to some technical reasons, the center of the umbrella must coincide with the center of a shopping mall. Furthermore, a fine survey shows that for any mall, covering half of its area is enough for people to seek shelter from the rain, so the task is to decide the minimum radius of the giant umbrella so that for every shopping mall, the umbrella can cover at least half area of the mall.
Input The input consists of multiple test cases. The first line of the input contains one integer T (1<=T<=10), which is the number of test cases. For each test case, there is one integer N (1<=N<=20) in the first line, representing the number of shopping malls. The following N lines each contain three integers X,Y,R, representing that the mall has a shape of a circle with radius R and its center is positioned at (X,Y). X and Y are in the range of [-10000,10000] and R is a positive integer less than 2000.
Output For each test case, output one line contains a real number rounded to 4 decimal places, representing the minimum radius of the giant umbrella that meets the demands.
Sample Input 1 2 0 0 1 2 0 1
Sample Output 2.0822
제목: 원 한 무 더 기 를 주 고 원 의 원심 을 골 라 반경 을 정 해서 이 원 이 다른 원 면적 의 절반 이상 을 덮 고 가장 작은 원 의 면적 을 출력 할 수 있 도록 하 는 것 이다.
문제 풀이 사고: 각 점 을 매 거 하고 2 분 의 방법 으로 반지름 2 분 구간 을 [0 으로 찾 아 원 의 반지름 길 이 를 완전 하 게 덮 습 니 다] 그리고 2 분 이면 됩 니 다. 2 분 은 원 면적 의 절반 을 덮 는 것 으로 판정 합 니 다.
그 중에서 교차 원 면적 을 계산 하 는 것 과 관련 된 것 은 이 문 제 를 먼저 볼 수 있 습 니 다. POJ 2546 상세 한 문제 풀이 와 교차 원 면적 을 계산 하 는 알고리즘 은 여 기 를 볼 수 있 습 니 다.http://blog.csdn.net/qq_33184171/article/details/51100090
알림: 본 문제 의 데이터 가 비교적 적 고 하나하나 열거 하면 시간 초과 문 제 를 걱정 하지 않 아 도 됩 니 다. 계산 기하학 이라는 문 제 는 상대 적 으로 관련 된 수학 공식 이 매우 많 습 니 다. 그 중에서 컴 파일 언어 에 반영 되면 매우 복잡 하기 때문에 템 플 릿 을 많이 정리 하고 경기 에 참가 할 때 많은 일 을 절약 할 수 있 습 니 다.
부본제 코드
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-8;
int n;
struct circle
{
double x,y,r;
} c[10005],ori;
double area[30];
double dis(circle &a,circle &b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double Area(circle &a)
{
return PI*a.r*a.r;
}
double getcrossarea(circle &a ,circle &b)
{
double d=dis(a,b);
if(d>=a.r+b.r) return 0;
if(d<=fabs(a.r-b.r))
{
double rr=min(a.r,b.r);
return PI*rr*rr;
}
double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2. / a.r / d);
double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2. / b.r / d);
double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
return ret;
}
bool check(circle & ori)
{
for(int i=0;i<n;i++)
{
if (getcrossarea(ori, c[i]) * 2 < PI * c[i].r * c[i].r)
return false;
}
return true;
}
double bin(double l, double r, circle& ori)
{
double mid;
while (fabs(l - r) >= EPS)
{
mid = (l + r) / 2;
ori.r = mid;
if (check(ori))
{
r = mid;
}
else
{
l = mid + EPS;
}
}
return mid;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=0; i<n; i++)
{
scanf("%lf%lf%lf",&c[i].x,&c[i].y,&c[i].r);
area[i]=Area(c[i]);
}
double ans = 1e10;
for(int i=0; i<n; i++)
{
ori.x = c[i].x;
ori.y = c[i].y;
double right = 0;
for(int j=0; j<n; j++)
{
right = max(right, dis(ori, c[j]) + c[j].r);
}
ans = min(ans, bin(0, right, ori));
}
printf("%.4f
", ans);
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
귀속할 필요가 없는 2점 찾기오늘 동료가 차에서 나에게 면접을 본다고 했는데, 이 문제가 있었는데, 그는 해내지 못했다 회사에 가서 직접 간단히 썼다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.