Paper Box Solution

$30.00

Description

The following figure shows a rectangular card of width W, length L, and thickness 0.

Four X by X squares are cut from the four corners of the card shown by the dotted lines. The card is then folded along the dashed lines to make a box without a cover.

Given the width and height of the box, find the values of X for which the box has largest and smallest volume.

Input

The input consists of several lines of input. Each line contains two positive floating point numbers L
W
, which are both less than 10,000, and indicate the length and width of the card, respectively.

Example Input

1 1
2 2
3 3

Output

For each input, output the value of X which produces the largest value followed by the positive value of X which produces the smallest volume. Each floating point number should contain three digits after the decimal point.

Note, since 0.000 would always yield the smallest volume, we ignore it and only want to determine the positive value of X that gives us the smallest box.

Example Output

0.167 0.500
0.333 1.000
0.500 1.500

Hints

Some things to consider:

  1. You will need to use a volume formula.

  2. You may need to take a derivative.

  3. You may need to use the quadratic formula.

Programming Challanges

This is based on 10215 – The Largest/Smallest Box problem on the UVa Online Judge.

Submission

To submit your work, follow the same procedure you used for Reading 00:

$ cd path/to/cse-30872-fa18-assignments     # Go to assignments repository
$ git checkout master                       # Make sure we are on master
$ git pull --rebase                         # Pull any changes from GitLab

$ git checkout -b challenge23               # Create and checkout challenge23 branch

$ $EDITOR challenge23/program.cpp           # Edit your code

$ git add challenge23/program.cpp           # Stage your changes
$ git commit -m "challenge23: done"         # Commit your changes

$ git push -u origin challenge23            # Send changes to GitLab

To check your code, you can use the .scripts/submit.py script or curl:

$ .scripts/submit.py
Submitting challenge23 assignment ...
Submitting challenge23 code ...
  Result Success
   Score 6.00
    Time 0.02

$ curl -F source=@challenge23/program.cpp  https://dredd.h4x0r.space/code/cse-30872-fa18/challenge23
{"score": 6, "result": "Success"}

Once you have commited your work and pushed it to GitLab, member to create a merge request. Refer to the Reading 11 TA List to determine your corresponding TA for the merge request.