Pie(poj 3122)

发布时间 2023-05-30 22:41:21作者: FISHQ

My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece of one pie, not several small pieces since that looks messy. This piece can be one whole pie though.

My friends are very annoying and if one of them gets a bigger piece than the others, they start complaining. Therefore all of them should get equally sized (but not necessarily equally shaped) pieces, even if this leads to some pie getting spoiled (which is better than spoiling the party). Of course, I want a piece of pie for myself too, and that piece should also be of the same size.

What is the largest possible piece size all of us can get? All the pies are cylindrical in shape and they all have the same height 1, but the radii of the pies can be different.

Input
One line with a positive integer: the number of test cases. Then for each test case:
One line with two integers N and F with 1 ≤ N, F ≤ 10 000: the number of pies and the number of friends.
One line with N integers ri with 1 ≤ ri ≤ 10 000: the radii of the pies.

Output
For each test case, output one line with the largest possible volume V such that me and my friends can all get a pie piece of size V. The answer should be given as a floating point number with an absolute error of at most 10−3.

Sample Input
3
3 3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2

Sample Output
25.1327
3.1416
50.2655


翻译:

我的生日快到了,按惯例我要做派。不只是一个馅饼,不,我有N个馅饼,有不同的口味和大小。我的朋友要来参加我的聚会,他们每个人都得到一块派。这应该是一块馅饼,而不是几块小馅饼,因为那样看起来很乱。这一块可以是一整块派。

我的朋友们都很烦人,如果他们中的一个人得到的比其他人大,他们就会开始抱怨。因此,所有的馅饼都应该是大小相等(但不一定是形状相等)的,即使这会导致一些馅饼被破坏(这比破坏聚会要好)。当然,我也想要一块馅饼给自己,那块馅饼也应该是同样大小的。

我们所有人能得到的最大尺寸是多少?所有的馅饼都是圆柱形的,它们都有相同的高度,但是馅饼的半径可以不同。

输入
一行是正整数:测试用例的数量。然后对于每个测试用例:
一行有两个整数N和F,其中1≤N, F≤10000:馅饼的数量和朋友的数量。
一行有N个整数ri,其中1≤ri≤10000:饼的半径。

输出
对于每个测试用例,输出一行最大的体积V,这样我和我的朋友都可以得到一个大小为V的饼块。答案应该是一个绝对误差不超过10−3的浮点数。

样例输入
3.
3个3
4 3 3
1 24
5
10 5
1 4 2 3 4 5 6 5 4 2 2

样例输出
25.1327
3.1416
50.2655