Statistics

Problem Statement for "ThePresents"

Problem Statement

Santa Claus has n small boxes, all of equal size, containing presents for the children. Each box is a A x A x A cube. Santa wants to pack all of the small boxes into a large rectangular box with dimensions length x width x height. Each small box must be placed inside the big box with its sides parallel to the sides of the big box.

Return the maximal possible value of A that will allow Santa Claus to fit all of the small boxes into the big one. Note that A is not necessarily an integer.

Definition

Class:
ThePresents
Method:
find
Parameters:
int, int, int, int
Returns:
double
Method signature:
double find(int n, int length, int width, int height)
(be sure your method is public)

Notes

  • The returned value must be accurate to within a relative or absolute value of 1E-9.

Constraints

  • n will be between 1 and 1,000,000,000, inclusive.
  • length, width and height will be between 1 and 1,000,000,000, inclusive.

Examples

  1. 2

    2

    2

    2

    Returns: 1.0

    There's room for eight 1x1x1 presents in the big box. However, if the presents are larger than 1x1x1, there is only room for one at most.

  2. 1

    12

    47

    5

    Returns: 5.0

    Just one present.

  3. 10

    4

    2

    10

    Returns: 2.0

    There will be no free space left in the big box.

  4. 77

    146

    523

    229

    Returns: 52.300000000000004

  5. 9

    9

    4

    1

    Returns: 1.0

  6. 4

    7

    3

    2

    Returns: 1.75

  7. 5

    9

    5

    4

    Returns: 2.5

  8. 757148

    167851001

    301413357

    336971125

    Returns: 2808092.7083333335

  9. 659598369

    160567226

    391749388

    4890852

    Returns: 77493.83494208494

  10. 35766291

    26239573

    473038165

    597007

    Returns: 58850.232022891265

  11. 3615545

    326051437

    392289611

    118341523

    Returns: 1606164.7142857143

  12. 170427799

    37215529

    675016434

    168544291

    Returns: 291095.493955095

  13. 683447134

    950090227

    82426873

    116752252

    Returns: 237285.27147852146

  14. 194041605

    706221269

    69909135

    257655784

    Returns: 402587.16250000003

  15. 84970744

    21417563

    37379061

    40873981

    Returns: 72601.90847457627

  16. 8670529

    80835681

    436291073

    653352031

    Returns: 1378379.812236287

  17. 106923811

    374079501

    466701607

    86546365

    Returns: 520277.47009735747

  18. 247776868

    480572137

    222071041

    36629217

    Returns: 250644.5158013544

  19. 366496749

    549646417

    278840199

    119255907

    Returns: 367863.0593667546

  20. 33557677

    379268590

    150378796

    137583463

    Returns: 614697.8768233387

  21. 7

    267851000

    401413356

    436971124

    Returns: 1.339255E8

  22. 3

    260567225

    491749387

    104890851

    Returns: 1.04890851E8

  23. 1

    126239572

    573038164

    100597006

    Returns: 1.00597006E8

  24. 3

    426051436

    492289610

    218341522

    Returns: 2.13025718E8

  25. 3

    137215528

    775016433

    268544290

    Returns: 1.37215528E8

  26. 900757147

    1

    1

    1

    Returns: 0.0010351966873706003

  27. 959598362

    2

    4

    4

    Returns: 0.003215434083601286

  28. 935766290

    1

    1

    3

    Returns: 0.0014734774066797642

  29. 903615544

    1

    3

    3

    Returns: 0.002150537634408602

  30. 1

    1000000000

    1000000000

    1000000000

    Returns: 1.0E9

  31. 1000000000

    1

    1

    1

    Returns: 0.0010

  32. 1000000000

    1000

    1000000

    1000000000

    Returns: 1000.0

  33. 1000000000

    300000000

    454360005

    235345346

    Returns: 317605.0553306343

  34. 100

    1

    1

    1

    Returns: 0.2

  35. 2

    1000000000

    1000000000

    1000000000

    Returns: 5.0E8

  36. 3

    1000000000

    1000000000

    1000000000

    Returns: 5.0E8

  37. 791051928

    329346118

    890347265

    111391486

    Returns: 345363.5628394104

  38. 1000000000

    1000000000

    1000000000

    1000000000

    Returns: 1000000.0

  39. 1

    2

    12

    1000000000

    Returns: 2.0

  40. 1000000000

    1

    1000000000

    999999999

    Returns: 1.0

  41. 9

    1000000000

    1000000000

    1000000000

    Returns: 3.333333333333333E8

  42. 897045453

    489418186

    516484864

    534534864

    Returns: 531875.4865671642

  43. 1

    989418186

    916484864

    934534864

    Returns: 9.16484864E8

  44. 1000000000

    1000000000

    999999999

    999999999

    Returns: 999999.999

  45. 1000000000

    1000000000

    1000000000

    1

    Returns: 1.0

  46. 1000000000

    1000000000

    999999999

    888888888

    Returns: 960960.96

  47. 5

    1000000000

    1000000000

    1000000000

    Returns: 5.0E8

  48. 1

    987045410

    985541354

    949516516

    Returns: 9.49516516E8


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: