LOGIN
  • Register
  • Forgot Password?

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
  • COMPETE
    • March Algorithm Challenge
    • February Algorithm Challenge
    • January Algorithm Challenge
    • December Algorithm Challenge
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • About Directi
    • Careers
Home » Compete » November 2009 (Contest X) » The Best Box

The Best Box

Problem code: J7

  • All Submissions

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:


  • Submit

Comments

  • Login or Register to post a comment.

Something is wrong with the

Stephen Merriman - 1st Nov,2009 16:06:39.

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

Ngô Minh Đức - 1st Nov,2009 16:57:22.

Yes, S and P should be swapped in the input description

I also agree! My accepted

Sandeep Pathak - 1st Nov,2009 17:47:35.

I also agree! My accepted solution is using the input other way!

It sure does seem so from the

Aniruddha (Codechef) - 1st Nov,2009 17:54:53.

It sure does seem so from the sample input/output. Will confirm and make changes accordingly.

With the input test case 1 a

Aditya - 1st Nov,2009 17:57:10.

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

Mahesh Chandra Sharma - 1st Nov,2009 18:07:53.

@ 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

Aniruddha (Codechef) - 1st Nov,2009 18:08:42.

Yes, please read the problem statement carefully.

The problem statement has

Aniruddha (Codechef) - 1st Nov,2009 18:24:40.

The problem statement has been updated.

Note : The time limit is 0.5

Aniruddha (Codechef) - 1st Nov,2009 19:02:24.

Note : The time limit is 0.5 seconds

admin... sir i am new to

daerty0153 - 1st Nov,2009 20:47:47.

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

Aniruddha (Codechef) - 1st Nov,2009 22:56:29.

Have you read the FAQ ? and www.codechef.com/wiki

My enthusiasm multiplies

Yashwant Vijayakumar - 1st Nov,2009 23:44:16.

My enthusiasm multiplies tenfold when I solve one problem! :) :)

can we print 3 for output

ANAND MOHAN - 2nd Nov,2009 09:41:28.

can we print 3 for output 3.00 ??

are two of the dimensions of

Zahid Aslam - 2nd Nov,2009 12:11:57.

are two of the dimensions of the box always equal???

@Zahid That is not mentioned

Aniruddha (Codechef) - 2nd Nov,2009 13:57:29.

@Zahid That is not mentioned in the problem statement.

I can not submit. when I

刘标勇 - 2nd Nov,2009 20:18:14.
I can not submit. when I access this page, a script error occur. description is "FB is not defined". I cancel this error. the content displayed. but I can not the see the time limited and the languages.

when I submit , the error

刘标勇 - 2nd Nov,2009 20:26:45.

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.

Aniruddha (Codechef) - 2nd Nov,2009 20:38:32.

We are looking into this. Will be fixed soon.

This is now fixed.

Aniruddha (Codechef) - 2nd Nov,2009 20:53:14.

This is now fixed.

can anyone tell me how to

kovid dutt - 3rd Nov,2009 16:42:19.

can anyone tell me how to input data in php on codechef

Read input from stdin and

Aniruddha (Codechef) - 3rd Nov,2009 17:38:00.

Read input from stdin and output to stdout. Check php manuals for more information.

What is the time limit of for

Giri - 4th Nov,2009 00:23:14.

What is the time limit of for the problem

0.5 seconds.

Aniruddha (Codechef) - 4th Nov,2009 02:12:58.

0.5 seconds.

Could you update the problem

Victor Hugo Soliz Kuncar - 4th Nov,2009 08:10:57.

Could you update the problem statement so that it says "0.5 seconds" instead of "s" ?

So, it is not possible that

Arjun Devane - 4th Nov,2009 08:36:29.

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

Victor Hugo Soliz Kuncar - 4th Nov,2009 09:16:03.

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

Victor Hugo Soliz Kuncar - 4th Nov,2009 09:19:14.

I was using g++ 4.3.2, when I switch to 4.0.0, it works.

here a testcase 40000 20000  

Elí De la Rosa Raymundo - 5th Nov,2009 08:01:07.

here a testcase

40000 20000   ----->>>>>>>>2499.75

i need more than these

please anybody can poste

Elí De la Rosa Raymundo - 5th Nov,2009 08:11:29.

please anybody can poste testcases

This is a contest problem.

Stephen Merriman - 5th Nov,2009 10:20:23.

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

Arjun Devane - 5th Nov,2009 10:34:18.

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

Arjun Devane - 5th Nov,2009 10:56:07.

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

ANAND MOHAN - 7th Nov,2009 09:04:54.

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

Ajay Nair - 7th Nov,2009 09:25:10.

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

Stephen Merriman - 7th Nov,2009 10:24:15.

The problem says he must use all of the wire and the paper.

ya thanks !! got a lil

Ajay Nair - 7th Nov,2009 11:06:39.

ya thanks !! got a lil confused if all implied only for wire , anyways i have understood it ! thanks

every time i upload , i get

vasudev karthik - 9th Nov,2009 16:47:38.

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

Pintu Kumar - 10th Nov,2009 12:01:41.
Hello Admin, My submission for Best Box is Accepted successfully, but why it is not showing under SUCCESSFUL SUBMISSIONS list.??? Also there is no rating. Please clarify... Thanks, Pintu

For example case #1 couldn't

Frank Rodriguez - 10th Nov,2009 20:54:50.

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

Frank Rodriguez - 10th Nov,2009 20:56:57.

Ah never mind, stupid question. I should have read more carefully.

how to submt the solution

akash chandrayan - 12th Nov,2009 15:36:29.

how to submt the solution

2.4

ayub - 12th Nov,2009 16:00:03.

2.4

This is added as a practice

Aniruddha (Codechef) - 12th Nov,2009 16:47:55.

This is added as a practice problem at www.codechef.com/problems/J7

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Fetching successful submissions
  • About CodeChef
  • About Directi
  • CEO's Corner
  • Careers
  • feedback@codechef.com
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
Sponsors
The time now is: