Statistics

Problem Statement for "PeopleCircle"

Problem Statement

There are numMales males and numFemales females arranged in a circle. Starting from a given point, you count clockwise and remove the K'th person from the circle (where K=1 is the person at the current point, K=2 is the next person in the clockwise direction, etc...). After removing that person, the next person in the clockwise direction becomes the new starting point. After repeating this procedure numFemales times, there are no females left in the circle.

Given numMales, numFemales and K, your task is to return what the initial arrangement of people in the circle must have been, starting from the starting point and in clockwise order.

For example, if there are 5 males and 3 females and you remove every second person, your return String will be "MFMFMFMM".

Definition

Class:
PeopleCircle
Method:
order
Parameters:
int, int, int
Returns:
String
Method signature:
String order(int numMales, int numFemales, int K)
(be sure your method is public)

Constraints

  • numMales is between 0 and 25 inclusive
  • numFemales is between 0 and 25 inclusive
  • K is between 1 and 1000 inclusive

Examples

  1. 5

    3

    2

    Returns: "MFMFMFMM"

    Return "MFMFMFMM". On the first round you remove the second person - "M_MFMFMM". Your new circle looks like "MFMFMMM" from your new starting point. Then you remove the second person again etc.

  2. 7

    3

    1

    Returns: "FFFMMMMMMM"

    Starting from the starting point you remove the first person, then you continue and remove the next first person etc. Clearly, all the females are located at the beginning. Hence return "FFFMMMMMMM"

  3. 25

    25

    1000

    Returns: "MMMMMFFFFFFMFMFMMMFFMFFFFFFFFFMMMMMMMFFMFMMMFMFMMF"

  4. 4

    1

    7

    Returns: "MFMMM"

  5. 3

    2

    7

    Returns: "MFMMF"

  6. 5

    1

    6

    Returns: "MMMMMF"

  7. 20

    25

    45

    Returns: "FFFFMFMMMFMMFFFFFFFFFMMFFMMFFMMMFMFFFMMMMFMMF"

  8. 7

    3

    10

    Returns: "FMFMMMMMMF"

  9. 0

    2

    1000

    Returns: "FF"

  10. 2

    0

    999

    Returns: "MM"

  11. 0

    0

    998

    Returns: ""

  12. 5

    5

    3

    Returns: "MFFMMFFMFM"

    Here we mark the removed people with '_', and the starting position with lower-case: Number of | People Remaining Rounds | (in initial order) ---------------+----------------- 0 | mFFMMFFMFM 1 | MF_mMFFMFM 2 | MF_MM_fMFM 3 | MF_MM_FM_m 4 | M__mM_FM_M 5 | M__MM__m_M

  13. 1

    0

    245

    Returns: "M"

  14. 0

    1

    23

    Returns: "F"

  15. 1

    1

    1

    Returns: "FM"

  16. 1

    1

    5

    Returns: "FM"

  17. 25

    0

    1000

    Returns: "MMMMMMMMMMMMMMMMMMMMMMMMM"

  18. 25

    25

    999

    Returns: "MFMMFMFFFFFMFFFFMFFMFMMMFMFMMMMMMMMFMFFFMFFMMMFFFM"

  19. 1

    25

    10

    Returns: "FFFFFFFFFFFFFFFMFFFFFFFFFF"

  20. 1

    25

    1000

    Returns: "FFFFFFFFFFFFMFFFFFFFFFFFFF"

  21. 14

    14

    32

    Returns: "MFMFFFMFFFFMFMFMMFMMMFMMFMFM"

  22. 17

    19

    111

    Returns: "FFFMMFFMFFFMFMFMFFFFMMMFFMMFMFFMMMMM"

  23. 5

    5

    3

    Returns: "MFFMMFFMFM"

  24. 25

    25

    1000

    Returns: "MMMMMFFFFFFMFMFMMMFFMFFFFFFFFFMMMMMMMFFMFMMMFMFMMF"

  25. 3

    3

    100

    Returns: "MFFFMM"

  26. 5

    5

    15

    Returns: "FMMFFMMMFF"

  27. 5

    5

    37

    Returns: "MMFMFFFFMM"

  28. 0

    1

    1

    Returns: "F"

  29. 5

    5

    30

    Returns: "FFFMMMMMFF"

  30. 0

    0

    1000

    Returns: ""

  31. 2

    0

    2

    Returns: "MM"

  32. 0

    1

    2

    Returns: "F"

  33. 5

    4

    100

    Returns: "FMFMFMFMM"

  34. 0

    0

    1

    Returns: ""

  35. 25

    25

    997

    Returns: "MFFFMMMMFFMFMFMMFMFMMMFMFFMFFMFMFFFMMMFMMFFFFMFMMF"


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: