Statistics

Problem Statement for "ExcitingGame"

Problem Statement

One day, nClassmates classmates decided to play an exciting game. They formed a circle and assigned themselves player numbers from 0 to nClassmates - 1 in a clockwise direction. Then, they counted from 1 to nTimes, inclusive, starting with player 0 and going in a clockwise direction. Each player spoke out the current number, and then, his clockwise neighbor spoke out the next number, etc. If a player got a number that was divisible by 3, he would cry out the word "hello" instead of speaking out the number. Return the number of times that player who cried out "hello".

Definition

Class:
ExcitingGame
Method:
howMany
Parameters:
int, int, int
Returns:
int
Method signature:
int howMany(int nClassmates, int nTimes, int who)
(be sure your method is public)

Constraints

  • nClassmates will be between 1 and 1000, inclusive.
  • nTimes will be between 1 and 10000, inclusive.
  • who will be between 0 and nClassmates - 1, inclusive.

Examples

  1. 2

    13

    0

    Returns: 2

    Player 0 cried out "hello" for the numbers 3 and 9.

  2. 10

    10

    1

    Returns: 0

    Player 1 only had one turn, and he spoke out the number 2.

  3. 3

    30

    2

    Returns: 10

    He cried out "hello" on all of his turns.

  4. 342

    10000

    341

    Returns: 29

  5. 453

    10000

    234

    Returns: 0

  6. 1

    7

    0

    Returns: 2

  7. 1

    18

    0

    Returns: 6

  8. 3

    39

    1

    Returns: 0

  9. 9

    64

    0

    Returns: 0

  10. 16

    123

    8

    Returns: 3

  11. 18

    67

    5

    Returns: 4

  12. 10

    216

    7

    Returns: 7

  13. 17

    310

    15

    Returns: 6

  14. 29

    365

    19

    Returns: 4

  15. 49

    558

    5

    Returns: 4

  16. 6

    755

    3

    Returns: 0

  17. 7

    372

    1

    Returns: 18

  18. 10

    577

    7

    Returns: 19

  19. 29

    476

    4

    Returns: 5

  20. 64

    1581

    60

    Returns: 8

  21. 85

    915

    38

    Returns: 4

  22. 88

    680

    43

    Returns: 3

  23. 191

    2433

    35

    Returns: 5

  24. 68

    2684

    52

    Returns: 13

  25. 356

    1935

    144

    Returns: 2

  26. 1

    1

    0

    Returns: 0

  27. 646

    1

    0

    Returns: 0

  28. 1000

    1

    0

    Returns: 0

  29. 1

    1450

    0

    Returns: 483

  30. 526

    7135

    0

    Returns: 4

  31. 1000

    5079

    0

    Returns: 2

  32. 1

    10000

    0

    Returns: 3333

  33. 316

    10000

    0

    Returns: 10

  34. 1000

    10000

    0

    Returns: 3

  35. 1

    1

    0

    Returns: 0

  36. 855

    1

    778

    Returns: 0

  37. 1000

    1

    166

    Returns: 0

  38. 1

    4499

    0

    Returns: 1499

  39. 895

    8544

    837

    Returns: 3

  40. 1000

    1171

    26

    Returns: 1

  41. 1

    10000

    0

    Returns: 3333

  42. 190

    10000

    107

    Returns: 18

  43. 1000

    10000

    899

    Returns: 4

  44. 1

    1

    0

    Returns: 0

  45. 158

    1

    157

    Returns: 0

  46. 1000

    1

    999

    Returns: 0

  47. 1

    1469

    0

    Returns: 489

  48. 879

    6469

    878

    Returns: 7

  49. 1000

    3568

    999

    Returns: 1

  50. 1

    10000

    0

    Returns: 3333

  51. 221

    10000

    220

    Returns: 15

  52. 1000

    10000

    999

    Returns: 3

  53. 702

    10000

    363

    Returns: 0

  54. 3

    3

    2

    Returns: 1


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: