This question is good! Very good, although I do not have AC. However, it is excitable. Of course, if there is no AC, there is no AC, but it is because you have used your own PI, resulting in no AC. I don't know. Can I forgive me?
This is the case. There are n pie and F friends who let you divide n pie into F + 1 so that these people can enjoy the same volume of pie. Of course, the shape doesn't matter, but you can't always use one on the other. Add up.
I think, isn't that the maximum value? The second answer is decisive. This is just a thought. However, it takes a long time to judge whether the enumerated answer is a qualified check function. It is also a while loop. However, I think the problem can still be solved in line with the meaning of the question, but it is wrong. I still cannot find the error. (Who will think of the reason for pi ?)
Then I thought about it. Let's take a look at the solution. At first glance, it's exactly the same as my method. It's just that people's check statements are very sharp. It's so sharp that I didn't think of it, and I don't know what to say. I did not think of it. Cry...
Now I have posted my own code. The deregistering part is the idea of the question solution (obviously simpler than mine ):
# Include <stdio. h> # include <string. h> # include <math. h >#include <iostream >#include <string> # include <algorithm> using namespace STD; const int maxn = 10011; const double Pi = ACOs (-1.0 ); int pie [maxn]; Double V [maxn]; double sum; int N, F; bool check (double key) {double N = sum; For (INT I = 0; I <n; I ++) {If (V [I] <key) {n-= V [I];} else {int CNT = 0; for (Int J = I; j <n; j ++) {double temp = V [J]; CNT + = (INT) floor (temp/Key );} if (CNT >=( F + 1) {return true;} else {return false ;}} if (N/(F + 1) <key) {return false ;}}/ * bool check (double key) {int CNT = 0; For (INT I = 0; I <n; I ++) {CNT + = (INT) floor (V [I]/Key);} If (CNT >=( F + 1) {return true ;} else {return false ;}} */INT main () {int t; scanf ("% d", & T); While (t --) {scanf ("% d", & N, & F); double max =-1.0; sum = 0; For (INT I = 0; I <N; I ++) {scanf ("% d", & Pie [I]); V [I] = (double) pie [I] * pie [I] * PI; max = max (max, V [I]); sum + = V [I];} Sort (V, V + n); // if you use a question, this sorting is not required, but it does not seem to affect the speed. I have the same time as the question. double left = 0; double right = max; while (right-left> 1e-5) {double mid = (left + right)/2; If (check (MID )) {left = mid;} else {right = mid;} printf ("%. 4lf \ n ", left);} // system (" pause "); Return 0 ;}