1
/*
2 二分好题
3 */
4
5 // include file
6 #include < cstdio >
7 #include < cstdlib >
8 #include < cstring >
9 #include < cmath >
10 #include < cctype >
11 #include < ctime >
12
13 #include < iostream >
14 #include < sstream >
15 #include < fstream >
16 #include < iomanip >
17 #include < bitset >
18
19 #include < algorithm >
20 #include < string >
21 #include < vector >
22 #include < queue >
23 #include < set >
24 #include < list >
25 #include < functional >
26
27 using namespace std;
28
29 // typedef
30 typedef long long LL;
31 typedef unsigned long long ULL;
32 typedef __int64 Bint;
33
34 //
35 #define read freopen("in.txt","r",stdin)
36 #define write freopen("out.txt","w",stdout)
37 #define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
38 #define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
39 #define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
40 #define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
41 #define FORii(a,b,c) for(int ii=(a);ii<(b);ii+=c)
42 #define FORjj(a,b,c) for(int jj=(a);jj<(b);jj+=c)
43 #define FORkk(a,b,c) for(int kk=(a);kk<(b);kk+=c)
44
45 #define FF(i,a) for(int i=0;i<(a);i++)
46 #define FFD(i,a) for(int i=(a)-1;i>=0;i--)
47
48 #define Z(a) (a<<1)
49 #define Y(a) (a>>1)
50
51 const double eps = 1e - 6 ;
52 const double INFf = 1e10;
53 const int INFi = 1000000000 ;
54 const double Pi = acos( - 1.0 );
55
56 template < class T > inline T sqr(T a){ return a * a;}
57 template < class T > inline T TMAX(T x,T y)
58 {
59 if (x > y) return x;
60 return y;
61 }
62 template < class T > inline T TMIN(T x,T y)
63 {
64 if (x < y) return x;
65 return y;
66 }
67 template < class T > inline void SWAP(T & x,T & y)
68 {
69 T t = x;
70 x = y;
71 y = t;
72 }
73 template < class T > inline T MMAX(T x,T y,T z)
74 {
75 return TMAX(TMAX(x,y),z);
76 }
77
78
79 // code begin
80 #define MAXN 10010
81 int T,N,F;
82 double R[MAXN],ans;
83 bool Isok( double lt)
84 {
85 int cnt = 0 ;
86 FORi( 0 ,N, 1 )
87 {
88 cnt += ( int )((Pi * R[i] * R[i]) / lt);
89 if (cnt >= F + 1 ) return true ;
90 }
91 return false ;
92 }
93 int main()
94 {
95 read;
96 write;
97 scanf( " %d " , & T);
98 while (T -- )
99 {
100 scanf( " %d %d " , & N, & F);
101 FORi( 0 ,N, 1 )
102 {
103 scanf( " %lf " , & R[i]);
104 }
105 double LL = 0 ,RR = Pi * MAXN * MAXN;
106 while ( RR - LL > eps)
107 {
108 double mid = (LL + RR) / 2 ;
109 if (Isok(mid))
110 {
111 LL = mid;
112 }
113 else
114 {
115 RR = mid;
116 }
117 }
118 printf( " %.4f\n " ,LL);
119 }
120 return 0 ;
121 }
2 二分好题
3 */
4
5 // include file
6 #include < cstdio >
7 #include < cstdlib >
8 #include < cstring >
9 #include < cmath >
10 #include < cctype >
11 #include < ctime >
12
13 #include < iostream >
14 #include < sstream >
15 #include < fstream >
16 #include < iomanip >
17 #include < bitset >
18
19 #include < algorithm >
20 #include < string >
21 #include < vector >
22 #include < queue >
23 #include < set >
24 #include < list >
25 #include < functional >
26
27 using namespace std;
28
29 // typedef
30 typedef long long LL;
31 typedef unsigned long long ULL;
32 typedef __int64 Bint;
33
34 //
35 #define read freopen("in.txt","r",stdin)
36 #define write freopen("out.txt","w",stdout)
37 #define FORi(a,b,c) for(int i=(a);i<(b);i+=c)
38 #define FORj(a,b,c) for(int j=(a);j<(b);j+=c)
39 #define FORk(a,b,c) for(int k=(a);k<(b);k+=c)
40 #define FORp(a,b,c) for(int p=(a);p<(b);p+=c)
41 #define FORii(a,b,c) for(int ii=(a);ii<(b);ii+=c)
42 #define FORjj(a,b,c) for(int jj=(a);jj<(b);jj+=c)
43 #define FORkk(a,b,c) for(int kk=(a);kk<(b);kk+=c)
44
45 #define FF(i,a) for(int i=0;i<(a);i++)
46 #define FFD(i,a) for(int i=(a)-1;i>=0;i--)
47
48 #define Z(a) (a<<1)
49 #define Y(a) (a>>1)
50
51 const double eps = 1e - 6 ;
52 const double INFf = 1e10;
53 const int INFi = 1000000000 ;
54 const double Pi = acos( - 1.0 );
55
56 template < class T > inline T sqr(T a){ return a * a;}
57 template < class T > inline T TMAX(T x,T y)
58 {
59 if (x > y) return x;
60 return y;
61 }
62 template < class T > inline T TMIN(T x,T y)
63 {
64 if (x < y) return x;
65 return y;
66 }
67 template < class T > inline void SWAP(T & x,T & y)
68 {
69 T t = x;
70 x = y;
71 y = t;
72 }
73 template < class T > inline T MMAX(T x,T y,T z)
74 {
75 return TMAX(TMAX(x,y),z);
76 }
77
78
79 // code begin
80 #define MAXN 10010
81 int T,N,F;
82 double R[MAXN],ans;
83 bool Isok( double lt)
84 {
85 int cnt = 0 ;
86 FORi( 0 ,N, 1 )
87 {
88 cnt += ( int )((Pi * R[i] * R[i]) / lt);
89 if (cnt >= F + 1 ) return true ;
90 }
91 return false ;
92 }
93 int main()
94 {
95 read;
96 write;
97 scanf( " %d " , & T);
98 while (T -- )
99 {
100 scanf( " %d %d " , & N, & F);
101 FORi( 0 ,N, 1 )
102 {
103 scanf( " %lf " , & R[i]);
104 }
105 double LL = 0 ,RR = Pi * MAXN * MAXN;
106 while ( RR - LL > eps)
107 {
108 double mid = (LL + RR) / 2 ;
109 if (Isok(mid))
110 {
111 LL = mid;
112 }
113 else
114 {
115 RR = mid;
116 }
117 }
118 printf( " %.4f\n " ,LL);
119 }
120 return 0 ;
121 }