Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save KT-Yeh/9037434 to your computer and use it in GitHub Desktop.

Select an option

Save KT-Yeh/9037434 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
const double pi = 2 * asin(1);
int Case,N, F;
int R[10001];
scanf("%d",&Case);
while (Case--){
scanf("%d%d", &N, &F);
F++;
int UP = 0; // BS上界
for (int i=0; i<N; i++){
scanf("%d",&R[i]);
R[i] *= R[i];
if (R[i] > UP) UP = R[i];
}
double left = 0, right = UP;
while (right-left > 0.00000001){
double mid = (left+right)/2;
int piece = 0;
for (int i=0; i<N; i++)
piece += R[i]/mid;
if (piece >= F) left = mid; //片數大於人數 因此往上逼近
else right = mid;
}
printf("%.3f\n",pi * left);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment