Practice on Toph
Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.
Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.
VHL is an international mail service company. Customers can send various packages to different places of the world via them.
VHL is planning to make a standard package box to contain the client's documents and stuff.
And they want to use different paper in different side of the box. And each paper costs different or maybe same.
The paper costs P$ Q$ and R$ per square meter for the bottom, sides and the top respectively.
The box have to have a total volume of V m3. Check the figure below:
The company wants to have the dimensions in a way such that the total cost of construction is as low as possible.
Now you need to write a program that will take P, Q, R and V as input and output the minimum cost of building the box.
Input starts with a positive integer T (≤ 500), denoting the number of test cases.
Each case starts with a line containing four real numbers denoting P, Q, R, V.
Each value is at least 1.0 and at most 104 and contains at most five places after the decimal point.
And P, Q, R will be distinct.
For each line of input produce a line of output. Each line will contain one real number denoting the minimum cost to build the box. Errors less than 10-6 will be ignored.
Input | Output |
---|---|
1 1 2 5 96 | 288.00000000 |
For the height=6, depth = 4, lenght = 4, we get the minimum cost of 288.
76% Solution Ratio
himuhasibEarliest,
StarscreamFastest, 0.0s
nfssdqLightest, 131 kB
SabbirsShortest, 141B
Login to submit