Statistics

Problem Statement for "Commission"

Problem Statement

*** You may only submit a given problem once - no resubmissions will be accepted. ***

Salesmen and saleswomen often work for a commission. In other words, they get to keep a certain percentage of the sales they make. You have a saleswoman working for you who gets a whopping 20% commission, which cuts deep into your profit margins. You are considering replacing her with a cheaper salesman who will keep commission% of his sales. Out of each sale, cost% of the sale goes towards the cost of your products and other overhead. Your current saleswoman sells $sales of products a year. Your task is to determine how much the potential salesman would have to sell in a year to make you the same profit.?

Definition

Class:
Commission
Method:
equivalentSales
Parameters:
double, double, double
Returns:
double
Method signature:
double equivalentSales(double sales, double cost, double commission)
(be sure your method is public)

Notes

  • Your result must have relative or absolute error of less than 1e-9.
  • The commission is based on the gross sale, not the part of the sale that is above and beyond the cost. Therefore, if sales were $1000, your current saleswoman's commission would be $200.
  • Note that neither sales nor the return value need to be in whole cents.

Constraints

  • sales will be between 1 and 1e10, inclusive.
  • cost will be between 0.5 and 79.5, inclusive.
  • commission will be between 0.5 and 19.5, inclusive.

Examples

  1. 100.555

    70.0

    10.0

    Returns: 50.2775

    If you hire the new salesman, your profit margin will double from 10% to 20%. Thus, in order to make the same profits, he needs only sell half as much.

  2. 756840

    74.3

    11.5

    Returns: 303801.971830986

    Your profit from your current saleswoman is $43139.88. If the potential salesman sells a little over $303801.97, your profit will also be the same.

  3. 10000000000

    79.5

    19.5

    Returns: 5.0E9

    Note that the exact answer is $5E9, but a return of $4.999999999999823E9, for example, has an error of $0.000177 which is a relative error of much less than 1e-9.

  4. 1e10

    0.5

    19.5

    Returns: 9.9375E9

  5. 1e10

    79.5

    0.5

    Returns: 2.5E8

  6. 8.43721326924896E9

    68.23599520710148

    6.251860358028325

    Returns: 3.8905164397896976E9

  7. 9.614646660519178E9

    9.895342436486649

    4.655836078244928

    Returns: 7.888131164524941E9

  8. 7.944156667578871E9

    72.41836889584326

    2.9313429527628

    Returns: 2.443365567059476E9

  9. 7.260833675727328E9

    11.418929884569774

    4.633100706928474

    Returns: 5.931718741026545E9

  10. 2.0746127364318938E9

    22.64220742995874

    11.691988834512387

    Returns: 1.8121335646584523E9

  11. 1.8306452010679398E9

    36.66797096334943

    18.410595141000577

    Returns: 1.7658735291653848E9

  12. 5.264633569918279E8

    59.87190051072578

    14.298778074889587

    Returns: 4.1025881621061015E8

  13. 3.6735972854196725E9

    17.029134770671543

    18.06905144637416

    Returns: 3.5643009968967166E9

  14. 4.573054142666119E9

    18.358345872989382

    13.682065099354112

    Returns: 4.1479153390936646E9

  15. 7.984716708616845E9

    64.3895524692775

    11.721898514122941

    Returns: 5.2177719601526985E9

  16. 2.4042298818893364E8

    20.494151393102438

    11.662931514081114

    Returns: 2.1087793022248238E8

  17. 2.47817639550108E9

    31.318728727639993

    4.746916867369422

    Returns: 1.8869476120139008E9

  18. 4.996936228037295E9

    76.350585393411

    2.859257098792855

    Returns: 8.771406398414612E8

  19. 9.091314478993944E9

    73.72019169441944

    14.910274517646714

    Returns: 5.021464665017376E9

  20. 6.534539845041672E9

    19.66943408579149

    18.430553580116193

    Returns: 6.368859584591379E9

  21. 4.542526576450711E9

    1.0335515680986662

    8.7088215601534

    Returns: 3.9742590524736853E9

  22. 5.731609554464256E9

    55.296680125977076

    9.85548832088176

    Returns: 4.0630873688946567E9

  23. 4.131705055736418E9

    27.219588754580133

    1.2474141949261388

    Returns: 3.0485664096055565E9

  24. 9.946869642678268E9

    48.44162556727712

    0.8045216547176959

    Returns: 6.184890790264513E9

  25. 7.646103454373939E9

    35.75761594507076

    9.255852306502309

    Returns: 6.152085516137515E9

  26. 1.2399359640902324E9

    21.754973004989843

    8.584996713113714

    Returns: 1.0367509662034758E9

  27. 8.752555831912825E9

    6.513563246227915

    5.937716571674271

    Returns: 7.346699520425918E9

  28. 5.003354990872392E9

    60.52583214236826

    3.0768994063626303

    Returns: 2.677018883272023E9

  29. 3.422359995200295E9

    71.2152718023831

    12.874485296845062

    Returns: 1.8896318893266916E9

  30. 2.598964065327838E9

    19.98726881332888

    6.039423486389426

    Returns: 2.1084758362879527E9

  31. 5.320123952779625E9

    54.592690939724044

    14.717027072856984

    Returns: 4.404326866812755E9

  32. 9.121112259343814E8

    58.43234952883726

    12.412208453095609

    Returns: 6.747315338106012E8

  33. 8.73347408388608E9

    21.527597653311037

    2.057687306151056

    Returns: 6.6828386423538885E9

  34. 7.983649183488454E9

    69.92054026418022

    0.5369999195981824

    Returns: 2.723905557982557E9

  35. 2.5365280222381577E9

    41.410442425386705

    4.255115000398136

    Returns: 1.801499923737706E9

  36. 6.983296107663028E9

    50.59368809971328

    2.1275415178144668

    Returns: 4.343450173783032E9

  37. 2.344918918375332E9

    42.75005208440239

    16.78683145431353

    Returns: 2.1587093435908976E9

  38. 7.399319145857055E9

    30.02059818057305

    14.375326462116877

    Returns: 6.650835256310949E9

  39. 5.881222812389608E9

    75.93162131485185

    2.527945332233495

    Returns: 1.1107966650678055E9

  40. 8.307698682448638E9

    4.501645030260655

    1.619685089469148

    Returns: 6.681151159353621E9

  41. 7.54288708241172E9

    67.20499050675615

    5.435686958195973

    Returns: 3.527547573675895E9

  42. 1.5368430181622431E9

    68.54515564435899

    15.871411208255633

    Returns: 1.1296803089283156E9

  43. 9.134943958952156E9

    7.921538377594148

    19.086530927436954

    Returns: 9.020623256558752E9

  44. 4.268211084728977E9

    33.883890100775695

    16.764238716239326

    Returns: 3.9883653190501714E9

  45. 2.0504570675327318E9

    57.965372527093386

    12.134115797400105

    Returns: 1.511046303240458E9

  46. 9.634234193425398E9

    45.744310960784944

    6.8380776872198386

    Returns: 6.960015936084612E9

  47. 2.175023147234453E9

    61.06222966380364

    1.6911366382143893

    Returns: 1.1058741354247205E9

  48. 7.936850206636174E9

    32.87821242653537

    5.817766067939422

    Returns: 6.10071835835127E9

  49. 8.248795056362733E9

    49.34506157148808

    5.186719627461921

    Returns: 5.561385759768835E9

  50. 9.67568196780663E9

    75.08329950457731

    2.6425198581110316

    Returns: 2.1357656696461496E9

  51. 1.100120128750106E9

    27.43423717733566

    18.10287486660254

    Returns: 1.0617992533001661E9

  52. 8.326025367840853E9

    72.99754913143863

    9.591320108702227

    Returns: 3.3485811101434083E9

  53. 9.297565596786016E9

    40.406362214946704

    2.980545136155373

    Returns: 6.502461308816779E9

  54. 6.143766427041953E9

    51.4754788380603

    11.120716840795613

    Returns: 4.685298692013166E9

  55. 3.549056262864414E9

    60.01081400760803

    12.929190463929928

    Returns: 2.6216835720184016E9

  56. 9.81625034316587E9

    51.420138041621264

    16.93223413009082

    Returns: 8.864711165043602E9

  57. 2.7412011268608195E8

    7.306957997395385

    8.93608724200775

    Returns: 2.3791009262698826E8

  58. 5.862888236790677E9

    72.832805442443

    17.780603413441227

    Returns: 4.476647594119693E9

  59. 4.822574642830569E9

    41.576085066556196

    17.30550386322547

    Returns: 4.506550545444533E9

  60. 3.8735230133727393E9

    65.78657777418557

    3.3508835264591132

    Returns: 1.783910864456067E9

  61. 7.913921699080601E9

    12.776200986665586

    14.457174701425274

    Returns: 7.311097453495468E9

  62. 1.2316974075493464E9

    5.9666997868706115

    15.917311076296672

    Returns: 1.1673234244669924E9

  63. 9.098493722151285E9

    11.399584936008234

    7.862255956803612

    Returns: 7.7306747230645275E9

  64. 7.3981094289717045E9

    20.239306056906333

    18.960172302662695

    Returns: 7.271584871539923E9

  65. 7.93505695834775E9

    12.134743969507358

    4.517965059878404

    Returns: 6.4610938858789835E9


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: