思路:就是二分派的体积,但是要处理一下高精度。
#include#include #include using namespace std;#define IP acos(-1.0)const int maxn = 1e4 + 10;#define ll long long#define max(a, b) (a)>(b)?(a):(b)int t, n, f;ll a[maxn];ll r, maxx;bool ok(ll x){ int ans = 0; for (int i = 0; i < n; ++i) { ans += a[i] / x; if (f + 1 <= ans)return 1; } return 0;}int main(){ scanf("%d", &t); while (t--){ maxx = 0; scanf("%d%d", &n, &f); for (int i = 0; i < n; ++i) { scanf("%lld", &r); a[i] = IP*r*r * 10000; maxx = max(maxx, IP*r*r*10000); } ll L = 0, R = maxx; while (R > L+1){ // cout << L << " " << R << endl; ll mid = (R + L) / 2.0; if (ok(mid))L = mid; else R = mid; } printf("%.4lf\n", R / 10000.0); }}