forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
28 lines (27 loc) · 624 Bytes
/
C.cpp
File metadata and controls
28 lines (27 loc) · 624 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
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int main()
{
ios::sync_with_stdio(0);
int test;
cin >> test;
while (test--)
{
int r[10100], n, f;
cin >> n >> f;
for (int i = 0; i < n; i++) cin >> r[i];
f++;
double low = 0, high = 1e8;
for (int it = 0; it < 100; it++)
{
double mid = (low + high) / 2;
int cnt = 0;
for (int i = 0; i < n; i++)
cnt += int(1.0 * r[i] * r[i] / mid);
if (cnt >= f) low = mid;
else high = mid;
}
cout << fixed << setprecision(4) << low * PI << endl;
}
}