Title Description
In a rectangular block house, a maximum of N (0≤N≤6) two distinct points, one point at any place where a very small droplets, then the droplets will have been extended until it contacts the other droplets border or frame of mind. Must wait for a finished oil droplets can be placed next expansion of oil droplets. Then the oil droplets should be placed on the N points according to what order, to make the total area of all the oil droplets have been placed after the largest occupied it? (Without merging the different droplets)
Note: the circle area formula PI = S r r, where r is the radius of the circle.Input Format
A first line integer N.
Second row rectangular frame and a vertex diagonal vertex coordinates, x, y, x ', y'.
Next N lines of two integers xi, yi, represent the coordinates of N points of the box.
All above data are [-1000,1000] within.
search for.
#include<bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535;
int x,y,xx,yy,n,ax[10],ay[10],vis[10];
long double maxn,r[10],dis[10][10];
long double sum(long double r){
return pi * r * r;
}
long double dist(long double x,long double y,long double xx,long double yy){
return sqrt((x - xx) * (x - xx) + (y - yy) * (y - yy));
}
void dfs(int cnt){
if(cnt == n + 1){
long double ans = 0;
for(int i = 1; i <= n; ++i)
ans += sum(r[i]);
maxn = max(ans,maxn);
}
for(int i = 1; i <= n; i++){
if(vis[i]) continue;
r[i] = min(min(abs(x - ax[i]),abs(xx-ax[i])),min(abs(y - ay[i]),abs(yy - ay[i])));
for(int j = 1; j <= n; ++j){
if(i != j && vis[j]) r[i] = min(r[i],max(dis[i][j] - r[j],(long double)0.0));
}
vis[i] = 1;
dfs(cnt + 1);
vis[i] = 0;
r[i] = 0x3f3f3f3f;
}
}
int main(){
cin >> n >> x >> y >> xx >> yy;
for(int i = 1; i <= n; i++){
cin >> ax[i] >> ay[i];
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
dis[i][j] = dis[j][i] = dist(ax[i],ay[i],ax[j],ay[j]);
for(int i = 1; i <= n; ++i) r[i] = 0x3f3f3f3f;
dfs(1);
long double ans = abs(x - xx) * abs(y - yy) - maxn;
cout << (long long)(ans + 0.5) << endl;
return 0;
}