05: Pi
- View
- Submit
- Statistics
- Questions
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
-
Describe
-
-
My birthday is coming! According to custom, I need to share some of the pies. I have n different tastes, different sizes of pies. f A friend will come to my party, everyone will get a piece of pie (must a piece of pie, not by a few pies of small pieces, can be a whole pie).
My friends are especially stingy, and if someone gets a bigger piece, they start complaining. So everyone gets a pie of the same size (but doesn't need to be the same shape), though some will be wasted, but it's better than screwing the whole party. Of course, I also want to give myself a piece, and this piece will be the same size as other people.
What is the maximum number of pies each of us get? Each faction is a cylinder with a height of 1 and a range of radii.
-
-
Input
-
The
-
first line contains two positive integers N and f,1≤n, F≤10 000, representing the number of pies and the number of friends.
The second line contains an integer of n 1 to 10000, representing the radius of each pie.
-
-
Output
-
-
output The maximum pie size that everyone can get, accurate to three digits after the decimal point.
-
-
Sample input
-
-
3 34 3 3
-
-
Sample output
-
25.133
Painful Lesson: floating-point numbers are best converted into integers to calculate, or the accuracy of the problem.
#include <iostream>#include<cstdio>using namespacestd;DoubleR,l,mid;Doublea[10010];intn,k,sum;intJudgeDoublex) { intAns,i; Ans=0; for(i=1; i<=n;i++) ans+=a[i]/x; returnans;}intMain () {inti; scanf ("%d%d",&n,&k); L=0; R=0; for(i=1; i<=n;i++) {scanf ("%LF",&A[i]); A[i]=a[i]*a[i]*3.141592653589793*100000; R=Max (r,a[i]); } //r=3.14159263589793*100000*100000;sum=0; while(l<r) {Mid= (r+l)/2; Sum=judge (mid); if(sum>=k+1) L=mid; ElseR=mid; if(r-l<1) Break; } if(Judge (R) ==k+1) printf ("%.3LF", r/100000); Elseprintf ("%.3LF", l/100000); return 0;}
"Noioj" p8211 (PS: Accuracy of the two-point floating-point number)