#include<bits/stdc++.h>
#define debu
using namespace std;
const double eps=1e-7;
const double pi=acos(-1.0);
const int maxn=1e4+50;
int n,f;
double maxarea,a[maxn];
int check(double area)
{
int num=0;
for(int i=0; i<n; i++)
num+=floor(a[i]/area);
return num>=f+1;
}
void solve()
{
double l=0.0,r=maxarea,mid;
while(r-l>eps)
{
mid=l+(r-l)/2;
if(check(mid)) l=mid;
else r=mid;
}
printf("%.4f\n",l);
}
int main()
{
#ifdef debug
freopen("in.in","r",stdin);
#endif // debug
int t;
scanf("%d",&t);
while(t--)
{
maxarea=0.0;
scanf("%d%d",&n,&f);
for(int i=0; i<n; i++)
{
int x;
scanf("%d",&x);
a[i]=x*x*pi;
maxarea=max(a[i],maxarea);
}
solve();
}
return 0;
}
题目地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1636
题解:最小值最大问题----二分答案。即能否使得f+1个人得到面积为x的派,判断答案是否合法即可。