Computer Science, asked by senaykt, 1 year ago


i need to solve this question in javascriptOffice party

There is an office party to celebrate the last quarter’s performance with cake for everyone! Many different circular cakes are ordered.
Given the radii of the circular cakes and the number of guests, determine the largest piece that can be cut from the cakes such that every guest gets a piece with the same area. It is not possible that a single piece has some part of one cake and some part of another cake. To be fair, every guest is served only one piece of cake.


NOTE: Use 3.14159265359 as the value of pi and return the answer runded to 4 places after the decimal. The answer is accepted if the absolute error is within 10^4
For example there are6 cakes with radii=[1,1,1,2,2,3] and there need to be numberOfGUESTS=6 equal size pieces. Area of cake with radious r is calculated as (pi * radius*radius)


For radii 1,2,and 3 the areas are 3.14159265359, 12.5663706156 and 28.2743338851 units^2


It would be possible to serve everyone a piece that matches the area of the circle with radius 1, but that would not be the biggest piece possible that cn be served to everyone
Best way to cut the cakes is to cut the largest cake into 4 pieces(area=28.743338851/4=7.068583471275 and a similar size piece from each of the cakes with radius 2.


So, the answer is 7.0686


Determine the largest piece that can b cut given the above conditions.


Function description:
The function must return the maximum possible area piece of cake rounded to 4 decimals and cast as a string.
Largest piece has the following parameters radii[radius[0]....radius[n-1]
numberOfGuests an integer
Constraints
1<=size of radii<=10^5
1<=radii<=10^4(where 0<=i<=size of radii)
1<=numberOfGuests<=10^5

Answers

Answered by khushi37280
1

l don't understand your question

Similar questions