The Best BoxProblem code: J7 |
All submissions for this problem are available.
Johnny needs to make a rectangular box for his physics class project. He has bought P cm of wire and S cm2 of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box.
What is the largest volume of the box that Johnny can make?
Input
The first line contains t, the number of test cases (about 10). Then t test cases follow.
Each test case contains two integers P and S in a line (1 ≤ P ≤ 40000, 1 ≤ S ≤ 20000). You may assume that there always exists an optimal solution for the given input cases.
Output
For each test case, print a real number that is the largest volume of the box that Johnny can make, rounded to two decimal places.
Example
Input: 2 20 14 20 16 Output: 3.00 4.15 Output details First case: the dimensions of the largest box may be 3, 1 and 1. Second case: the dimensions of the largest box may be 7/3, 4/3 and 4/3.
| Date: | 2009-10-15 |
| Time limit: | s |
| Source limit: | 50000 |
| Languages: |
Comments

Fetching successful submissions

Something is wrong with the
Something is wrong with the sample input/problem description. It appears S and P are the wrong way around, because with sides of 3, 1, and 1, the total perimeter is 20 which is greater than P=14 for the first test case.
Yes, S and P should be
Yes, S and P should be swapped in the input description
I also agree! My accepted
I also agree! My accepted solution is using the input other way!
It sure does seem so from the
It sure does seem so from the sample input/output. Will confirm and make changes accordingly.
With the input test case 1 a
With the input test case 1 a cube of side 1.52 can be made, perimeter = 18.24, surface area = 13.86 whose volume is 3.51. Am I wrong in this interpretation?
@ admin......input output
@ admin......input output test case is given wrong..
by the way which value will come first in the test case??? P or S??
Yes, please read the problem
Yes, please read the problem statement carefully.
The problem statement has
The problem statement has been updated.
Note : The time limit is 0.5
Note : The time limit is 0.5 seconds
admin... sir i am new to
admin...
sir i am new to codechef and am not understanding the method to submit a problem as in this case where am i getting input from? and if i am getting string input do i have to pass it in main()??please tell me the method to submit a problem. thanks
Have you read the FAQ ? and
Have you read the FAQ ? and www.codechef.com/wiki
My enthusiasm multiplies
My enthusiasm multiplies tenfold when I solve one problem! :) :)
can we print 3 for output
can we print 3 for output 3.00 ??
are two of the dimensions of
are two of the dimensions of the box always equal???
@Zahid That is not mentioned
@Zahid That is not mentioned in the problem statement.
I can not submit. when I
when I submit , the error
when I submit , the error message is "You can't submit in this language for this problem. Try link."
I use c#2.0,
and my os is xp + sp2, browser is IE7 (firefox error too.)
We are looking into this.
We are looking into this. Will be fixed soon.
This is now fixed.
This is now fixed.
can anyone tell me how to
can anyone tell me how to input data in php on codechef
Read input from stdin and
Read input from stdin and output to stdout. Check php manuals for more information.
What is the time limit of for
What is the time limit of for the problem
0.5 seconds.
0.5 seconds.
Could you update the problem
Could you update the problem statement so that it says "0.5 seconds" instead of "s" ?
So, it is not possible that
So, it is not possible that some material, either wire or paper is wasted.
Becasue if it can be wasted then volume could be maximized more.
Arjun Devane: The statement
Arjun Devane: The statement was clear in that regards.
I can't submit in C++ get that same error "can't submit in this language for that problem"
I was using g++ 4.3.2, when I
I was using g++ 4.3.2, when I switch to 4.0.0, it works.
here a testcase 40000 20000
here a testcase
40000 20000 ----->>>>>>>>2499.75
i need more than these
please anybody can poste
please anybody can poste testcases
This is a contest problem.
This is a contest problem. You will not be given extra help, and please don't spoil the problem for others by posting test cases (either correct or incorrect) yourself.
for those getting time limit
for those getting time limit exceed error.
try a more mathematically sound approach. if you are good enough to be in high school, then you are good enough to solve this problem mathematically.
And one more problem Ive been
And one more problem Ive been getting always, while solving practice probs as well as this nov challenge.
When I submit my solutions in PHP, they get rejected for time limit crossing. Sometimes the algorithm it is my mistake becaouse my method is time consuming. But in some cases, like this problem's. I submitted my solution in C. And it got accepted. But the same solution when I converted into PHP. It got rejected for exceeding time limit. And yes, I kept the same algorithm, infact I just edited C code to look like PHP, nothing much more.
PHP being a interpreted language, I am assuming you have allowed some slack time for sch languages. Sometimes I get that feeling becasue the script run time (shown in successful submission) crosses time limit mark in the problem page.
But now I am thinking if such slack time is available for PHP it might not be enough.
But any case, I will be trying to submit in C first, becasue you know, getting rejected is frustating. ;).
i think my solution is
i think my solution is correct.....its giving corrrect answer to almost all the tst cases i can think off...so judge please check it out..
just to clarify we have to
just to clarify we have to use all the length of the wire ( compulsorily ) but less than or equal to the area of the paper for making the box ?
The problem says he must use
The problem says he must use all of the wire and the paper.
ya thanks !! got a lil
ya thanks !! got a lil confused if all implied only for wire , anyways i have understood it ! thanks
every time i upload , i get
every time i upload , i get wrong answer but in my computer i get the right answer for the given test cases....
can u please tell me what to do ?
Hello Admin, My submission
For example case #1 couldn't
For example case #1 couldn't you build a box with sides of 1.527525 and obtain a box with area 3.56? Why is the answer 3.00?
Ah never mind, stupid
Ah never mind, stupid question. I should have read more carefully.
how to submt the solution
how to submt the solution
2.4
2.4
This is added as a practice
This is added as a practice problem at www.codechef.com/problems/J7