CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • February Long Contest
    • January CookOff
    • January Long Contest
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
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

triplem @ 1 Nov 2009 04:06 PM

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

Walrus @ 1 Nov 2009 04:57 PM

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

I also agree! My accepted

pathaksandeep @ 1 Nov 2009 05:47 PM

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

It sure does seem so from the

admin @ 1 Nov 2009 05:54 PM

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

With the input test case 1 a

avd122 @ 1 Nov 2009 05:57 PM

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

mcsharma1990 @ 1 Nov 2009 06:07 PM

@ 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

admin @ 1 Nov 2009 06:08 PM

Yes, please read the problem statement carefully.

The problem statement has

admin @ 1 Nov 2009 06:24 PM

The problem statement has been updated.

Note : The time limit is 0.5

admin @ 1 Nov 2009 07:02 PM

Note : The time limit is 0.5 seconds

admin... sir i am new to

kartik godawat @ 1 Nov 2009 08:47 PM

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

admin @ 1 Nov 2009 10:56 PM

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

My enthusiasm multiplies

yashwa7 @ 1 Nov 2009 11:44 PM

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

can we print 3 for output

sai4anand @ 2 Nov 2009 09:41 AM

can we print 3 for output 3.00 ??

are two of the dimensions of

Zahid1991 @ 2 Nov 2009 12:11 PM

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

@Zahid That is not mentioned

admin @ 2 Nov 2009 01:57 PM

@Zahid That is not mentioned in the problem statement.

I can not submit. when I

liubiaoyong @ 2 Nov 2009 08:18 PM
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

liubiaoyong @ 2 Nov 2009 08:26 PM

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.

admin @ 2 Nov 2009 08:38 PM

We are looking into this. Will be fixed soon.

This is now fixed.

admin @ 2 Nov 2009 08:53 PM

This is now fixed.

can anyone tell me how to

Kovid Dutt @ 3 Nov 2009 04:42 PM

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

Read input from stdin and

admin @ 3 Nov 2009 05:38 PM

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

What is the time limit of for

sesha_giri_nit @ 4 Nov 2009 12:23 AM

What is the time limit of for the problem

0.5 seconds.

admin @ 4 Nov 2009 02:12 AM

0.5 seconds.

Could you update the problem

vexorian @ 4 Nov 2009 08:10 AM

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

So, it is not possible that

arjundevane @ 4 Nov 2009 08:36 AM

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

vexorian @ 4 Nov 2009 09:16 AM

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

vexorian @ 4 Nov 2009 09:19 AM

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

here a testcase 40000 20000  

zeylk @ 5 Nov 2009 08:01 AM

here a testcase

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

i need more than these

please anybody can poste

zeylk @ 5 Nov 2009 08:11 AM

please anybody can poste testcases

This is a contest problem.

triplem @ 5 Nov 2009 10:20 AM

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

arjundevane @ 5 Nov 2009 10:34 AM

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

arjundevane @ 5 Nov 2009 10:56 AM

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

sai4anand @ 7 Nov 2009 09:04 AM

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

prodigyaj @ 7 Nov 2009 09:25 AM

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

triplem @ 7 Nov 2009 10:24 AM

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

ya thanks !! got a lil

prodigyaj @ 7 Nov 2009 11:06 AM

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

every time i upload , i get

vasudk2009 @ 9 Nov 2009 04:47 PM

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_agarwal @ 10 Nov 2009 12:01 PM
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

frank44 @ 10 Nov 2009 08:54 PM

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

frank44 @ 10 Nov 2009 08:56 PM

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

how to submt the solution

Akash Chandrayan @ 12 Nov 2009 03:36 PM

how to submt the solution

2.4

ayub @ 12 Nov 2009 04:00 PM

2.4

This is added as a practice

admin @ 12 Nov 2009 04:47 PM

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

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languages. Online programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming competitions that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com