Statistics

Problem Statement for "FlightScheduler"

Problem Statement

The Breguet range equation tells us how far an aircraft can fly if it has a given mass of fuel on board. It states that the maximum range of an aircraft R is given by:
R = K * ln(take-off mass / empty mass)
where K is a constant for the aircraft and the take-off mass is equal to the empty mass + the mass of fuel on board the aircraft. In addition, taking off and gaining altitude takes a certain, constant amount of fuel.

An airline wishes to minimize the amount of fuel consumed on a given journey by allowing the aircraft to stop at intermediate cities along the way to refuel. Assume that the aircraft can stop an unlimited number of times and can stop at any point of its journey. Also assume that it can carry an unlimited amount of fuel.

You will be given an int distance, the total distance of the journey, the int value K for the aircraft, an int emptyMass containing the empty mass of the aircraft and an int takeoffFuel containing the additional mass of fuel required each time the aircraft takes off. You should return a double containing the minimum amount of fuel required to complete the journey.

Definition

Class:
FlightScheduler
Method:
minimizeFuel
Parameters:
int, int, int, int
Returns:
double
Method signature:
double minimizeFuel(int distance, int K, int emptyMass, int takeoffFuel)
(be sure your method is public)

Notes

  • The return value must be accurate to within an absolute or relative tolerance of 1e-9.

Constraints

  • distance will be between 1 and 200,000, inclusive.
  • K will be between 1 and 200,000, inclusive.
  • emptyMass will be between 1 and 200,000, inclusive.
  • takeoffFuel will be between 1 and 200,000, inclusive.

Examples

  1. 40000

    100000

    150000

    5000

    Returns: 76420.82744805096

    The optimal schedule here is to make 1 stop right in the middle of the flight.

  2. 40000

    55000

    150000

    5000

    Returns: 138450.61724934017

    K is a measure of the efficiency of the aircraft. With this less efficient aircraft it's best to stop twice.

  3. 1000

    500

    1000

    50

    Returns: 2664.9853821314487

  4. 10000

    100

    200

    5

    Returns: 24635.869665316768

  5. 100000

    50

    600

    2

    Returns: 1299304.0427867468

  6. 150000

    1

    150000

    1

    Returns: 2.2582208368425556E10

  7. 12197

    29451

    12718

    32501

    Returns: 39026.31721326991

  8. 20607

    28917

    19654

    19562

    Returns: 39989.17092307296

  9. 29736

    10528

    25877

    16975

    Returns: 172324.12469702153

  10. 21058

    23220

    19183

    1591

    Returns: 25085.657435445617

  11. 30308

    11772

    25672

    2519

    Returns: 97520.36786129391

  12. 24768

    25205

    29304

    18875

    Returns: 67858.362827057

  13. 6659

    8997

    25915

    25655

    Returns: 54063.5346710648

  14. 15997

    29998

    24316

    7327

    Returns: 24457.500644322783

  15. 17538

    29859

    20051

    7866

    Returns: 23891.42563843786

  16. 528

    21402

    16588

    5749

    Returns: 6163.325586698862

  17. 132012

    4092

    141596

    136500

    Returns: 1.2252181131019197E7

  18. 31749

    113800

    105042

    123282

    Returns: 157083.82292453357

  19. 144012

    2

    149866

    1

    Returns: 1.0830696881014162E10

  20. 105600

    53088

    142186

    9160

    Returns: 390312.21653136547

  21. 80300

    130743

    140222

    138212

    Returns: 257140.48138689072

  22. 146078

    6355

    124698

    105111

    Returns: 7328605.984328408

  23. 84480

    133200

    105448

    110262

    Returns: 203644.394951216

  24. 12960

    138322

    115084

    63960

    Returns: 75264.02264476861

  25. 125131

    56056

    14100

    142880

    Returns: 260203.46807218198

  26. 112156

    46368

    24650

    1848

    Returns: 84157.96997191163

  27. 42768

    144400

    12298

    127280

    Returns: 131519.22553615

  28. 97539

    131104

    19200

    97284

    Returns: 118486.51986899413

  29. 131040

    60800

    115350

    147130

    Returns: 741290.5188633981

  30. 20184

    12921

    95700

    111384

    Returns: 449342.1451898261

  31. 145000

    10980

    103885

    95985

    Returns: 3624819.2190171042

  32. 129280

    15200

    133950

    18624

    Returns: 1790851.8724892882

  33. 146478

    1

    103432

    4

    Returns: 1.5283950796441101E10

  34. 147777

    1

    100000

    1

    Returns: 1.4843837124166306E10

  35. 140000

    4

    10000

    10

    Returns: 3.6576871282155204E8

  36. 127777

    1

    150000

    1

    Returns: 1.923657892461537E10

  37. 200000

    1

    200000

    1

    Returns: 4.012655775551904E10

  38. 99999

    99999

    99999

    99999

    Returns: 271825.4645640761

  39. 200000

    1

    100000

    1

    Returns: 2.0089509360950325E10

  40. 140000

    1

    10000

    1

    Returns: 1.4198456017490478E9

  41. 140000

    4

    10000

    1

    Returns: 3.5496140043726254E8

  42. 140000

    1

    200000

    10

    Returns: 2.828046627881105E10

  43. 200000

    1

    150000

    1

    Returns: 3.0109611157900635E10

  44. 20000

    1

    20000

    1

    Returns: 4.040066611258699E8

  45. 190000

    1

    10000

    1

    Returns: 1.926933316659421E9

  46. 200000

    1

    43243

    1

    Returns: 8.707483633296806E9

  47. 100000

    1

    100000

    1

    Returns: 1.0044754680475334E10

  48. 123567

    12

    123

    1519

    Returns: 1.1728119506754944E7

  49. 200000

    1

    200000

    200000

    Returns: 1.0873127313836182E11

  50. 200000

    1

    1

    200000

    Returns: 4.440495288922814E9


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: