-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPIEnew.cpp
More file actions
47 lines (42 loc) · 917 Bytes
/
PIEnew.cpp
File metadata and controls
47 lines (42 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
int t,i,n,f;
cin>>t;
while(t--)
{
cin>>n>>f;
f++;
int r[n];
for(i=0;i<n;i++)
{
cin>>r[i];
r[i]=r[i]*r[i];
}
sort(r,r+n,greater<int>());
double lo=0.0000;
double hi=4e8;
double mid;
int c=0;
long long int count1=0;
while(1)
{ count1=0;
c++;
mid=(lo+hi)/2;//cout<<"----";
for(i=0;i<n;i++)
{
count1+=(long long int)floor((M_PI*r[i])/mid);
}
if(count1>=f)
lo=mid;
else
hi=mid;
if(c==10000)
break;
}
//cout<<lo<<"\n";
printf("%.4f\n",lo);
}
}