Statistics

Problem Statement for "Conveyor"

Problem Statement

A package starts at the bottom of an inclined conveyor belt. Every minute, the conveyor belt moves the package up a certain number of feet. Then it pauses so that items on the belt can be inspected. While it is paused, the package slides down the belt a certain number of feet

Given the height of the belt (in feet), the height that a package goes up every minute (in feet), and the height it slides back down during every pause (in feet), return the number of minutes it will take for the package to reach the top.

For example, if the belt is 10 feet high, the belt goes up 3 feet every minute, and falls back down 2 feet during every pause:

During the 1st minute, it will go up to 3 feet and then slide back down to 1.
During the 2nd minute, it will go up to 4 feet and then slide back down to 2.
During the 3rd minute, it will go up to 5 feet and then slide back down to 3.
During the 4th minute, it will go up to 6 feet and then slide back down to 4.
During the 5th minute, it will go up to 7 feet and then slide back down to 5.
During the 6th minute, it will go up to 8 feet and then slide back down to 6.
During the 7th minute, it will go up to 9 feet and then slide back down to 7.
During the 8th minute, it will go up to 10 feet and leave the inclined belt.

Therefore, it would take the package 8 minutes to reach the top.

Definition

Class:
Conveyor
Method:
move
Parameters:
int, int, int
Returns:
int
Method signature:
int move(int height, int rateUp, int rateDown)
(be sure your method is public)

Notes

  • The package has reached the top when its maximum height is greater than or equal to the height of the belt.
  • You need not worry about the package sliding down during the minute that the conveyor belt is moving.
  • The first day is day 1.

Constraints

  • height will be between 10 and 100, inclusive.
  • rateUp will be between 2 and 10, inclusive.
  • rateDown will be between 1 and 9, inclusive.
  • rateUp will be less than or equal to height.
  • rateDown will be less than rateUp.

Examples

  1. 10

    3

    2

    Returns: 8

    This is the example from above.

  2. 100

    10

    1

    Returns: 11

  3. 100

    2

    1

    Returns: 99

  4. 50

    6

    2

    Returns: 12

  5. 92

    5

    3

    Returns: 45

  6. 100

    10

    9

    Returns: 91

  7. 50

    7

    5

    Returns: 23

  8. 26

    3

    2

    Returns: 24

  9. 78

    8

    3

    Returns: 15

  10. 38

    5

    2

    Returns: 12

  11. 88

    10

    2

    Returns: 11

  12. 20

    2

    1

    Returns: 19

  13. 10

    9

    8

    Returns: 2

  14. 10

    6

    5

    Returns: 5

  15. 69

    9

    6

    Returns: 21

  16. 10

    3

    2

    Returns: 8

  17. 10

    8

    1

    Returns: 2

  18. 100

    6

    5

    Returns: 95

  19. 10

    10

    1

    Returns: 1

  20. 11

    5

    1

    Returns: 3

  21. 10

    7

    6

    Returns: 4

  22. 10

    6

    1

    Returns: 2

  23. 10

    10

    9

    Returns: 1

  24. 92

    5

    3

    Returns: 45

  25. 10

    5

    2

    Returns: 3

  26. 14

    4

    1

    Returns: 5

  27. 19

    7

    2

    Returns: 4


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: