Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:38:19+00:00 2026-06-15T10:38:19+00:00

Johnny needs to make a rectangular box for his physics class project. He has

  • 0

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.

This is a practice problem from http://www.codechef.com. The name is “The Best box“. I don’t want the code for this. All I want to know is that how do we solve the problem? Any help would be appreciated. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:38:21+00:00Added an answer on June 15, 2026 at 10:38 am

    You are actually trying to solve:

    maximize V=a*b*c
    
    subject to constraints:
    
    4a+4b+4c = P 
    2ab + 2ac + 2bc = S
    

    This is a mathematical problem that can be solved using lagrange multipliers (Leaving developing the rest to you as an excercise – it is mostly technical, and if done slowly with care, shouldn’t be a problem).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one class I have has only protected variable attributes like int health and
Given the following code: <div id=bla> <p class=blubber>Johnny Bananas</p> </div> and the style in
User first_name: Johnny age: 15 Car name: Mazda Car name: BMW I would like
I’m working on creating a full-screen 3-D app (based on Johnny Lee's Wii head
An example signature may be: On Tue, Mar 20, 2012 at 2:38 PM, Johnny
Has anyone of you ever used php_writeexcel (http://www.bettina-attack.de/jonny/view.php/projects/php_writeexcel/)? I would like to know if
I have a file that looks something like this. Kate Johnny Bill Kermit I
Here's an input HTML string: <p> Johnny: My favorite color is pink<br /> Sarah:
Given the following XML, <Container> <Set > <RecommendedCoverSong>Hurt by NiN - Johnny Cash</RecommendedCoverSong> <RecommendedOriginalSong>She
I'm doing a small project to help my work go by faster. I currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.