Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector <int> pies;
- double binarysearch( double l, double r, int f){
- int soma=0;
- double mid=(l+r)/2;
- for(int i=0; i<pies.size(); i++){
- soma+=pies[i]/mid;
- }
- if(abs(r-l)<0.00001) return mid;
- if(soma >= f+1) return binarysearch(mid, r, f);
- return binarysearch(l,mid,f);
- }
- int main(){
- int t, n,f,aux;
- cin>>t;
- for(int i=0;i<t;i++){
- int ma=0;
- cin>>n>>f;
- for(int j=0;j<n;j++){
- cin>>aux;
- pies.push_back(aux*aux);
- ma=max(ma,aux*aux);
- }
- printf("%.4f\n", binarysearch(0,ma,f)*M_PI);
- pies.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement