Statistics

Problem Statement for "ChangesInTheLead"

Problem Statement

In a hockey game the score is a pair of numbers: the number H of goals scored by the home team and the number A of goals scored by the away team.

At some intermediate point during the game, the leader is the team that scored more goals so far. If both teams scored the same number of goals, there is no leader at that point in time.

At some intermediate point during the game, the most recent leader is the team that was most recently a leader during this game. (If there currently is a leader, that team is also the most recent leader. There is no most recent leader before the first goal of the game is scored.)

A change in the lead occurs whenever a goal is scored and the most recent leader immediately before the goal exists and differs from the most recent leader immediately after the goal.

For example, consider a match in which the score changed as follows: 0:0, 1:0, 1:1, 2:1, 2:2, 2:3, 2:4, 3:4, 4:4, 5:4, 6:4. In this match there were two changes in the lead: the first one was when the score became 2:3, and the second one was when the score became 5:4.

You are given the final score of a match, i.e., the ints H and A. You are also given the int C: the number of changes in the lead during the match. Count all different sequences in which the home and away team could have scored the goals, and return that count modulo 1,000,000,007.

Definition

Class:
ChangesInTheLead
Method:
count
Parameters:
int, int, int
Returns:
int
Method signature:
int count(int H, int A, int C)
(be sure your method is public)

Constraints

  • H will be between 0 and 250, inclusive.
  • A will be between 0 and 250, inclusive.
  • C will be between 0 and 250, inclusive.

Examples

  1. 7

    0

    0

    Returns: 1

    The home team scored seven goals in a row. There were no changes in the lead.

  2. 0

    6

    250

    Returns: 0

    This is impossible. Given that the final score is 0:6, the away team must have scored six goals in a row and there could not be any changes in the lead. Thus, there are no matches in which the final score is 0:6 and the number of changes in the lead is 250.

  3. 3

    1

    1

    Returns: 1

    There is exactly one sequence of goals that matches these inputs: the away team took an early lead 0:1 and then the home team scored three goals in a row.

  4. 6

    4

    2

    Returns: 35

    One of the 35 possibilities is the one mentioned in the problem statement.

  5. 6

    7

    3

    Returns: 208

  6. 0

    0

    0

    Returns: 1

    The game in which nobody scores a goal has zero changes in the lead.

  7. 250

    250

    250

    Returns: 0

  8. 0

    0

    1

    Returns: 0

  9. 0

    0

    2

    Returns: 0

  10. 0

    0

    3

    Returns: 0

  11. 0

    0

    4

    Returns: 0

  12. 0

    1

    0

    Returns: 1

  13. 0

    1

    1

    Returns: 0

  14. 0

    1

    2

    Returns: 0

  15. 0

    1

    3

    Returns: 0

  16. 0

    1

    4

    Returns: 0

  17. 0

    2

    0

    Returns: 1

  18. 0

    2

    1

    Returns: 0

  19. 0

    2

    2

    Returns: 0

  20. 0

    2

    3

    Returns: 0

  21. 0

    2

    4

    Returns: 0

  22. 0

    3

    0

    Returns: 1

  23. 0

    3

    1

    Returns: 0

  24. 0

    3

    2

    Returns: 0

  25. 0

    3

    3

    Returns: 0

  26. 0

    3

    4

    Returns: 0

  27. 1

    0

    0

    Returns: 1

  28. 1

    0

    1

    Returns: 0

  29. 1

    0

    2

    Returns: 0

  30. 1

    0

    3

    Returns: 0

  31. 1

    0

    4

    Returns: 0

  32. 1

    1

    0

    Returns: 2

  33. 1

    1

    1

    Returns: 0

  34. 1

    1

    2

    Returns: 0

  35. 1

    1

    3

    Returns: 0

  36. 1

    1

    4

    Returns: 0

  37. 1

    2

    0

    Returns: 2

  38. 1

    2

    1

    Returns: 1

  39. 1

    2

    2

    Returns: 0

  40. 1

    2

    3

    Returns: 0

  41. 1

    2

    4

    Returns: 0

  42. 1

    3

    0

    Returns: 3

  43. 1

    3

    1

    Returns: 1

  44. 1

    3

    2

    Returns: 0

  45. 1

    3

    3

    Returns: 0

  46. 1

    3

    4

    Returns: 0

  47. 2

    0

    0

    Returns: 1

  48. 2

    0

    1

    Returns: 0

  49. 2

    0

    2

    Returns: 0

  50. 2

    0

    3

    Returns: 0

  51. 2

    0

    4

    Returns: 0

  52. 2

    1

    0

    Returns: 2

  53. 2

    1

    1

    Returns: 1

  54. 2

    1

    2

    Returns: 0

  55. 2

    1

    3

    Returns: 0

  56. 2

    1

    4

    Returns: 0

  57. 2

    2

    0

    Returns: 4

  58. 2

    2

    1

    Returns: 2

  59. 2

    2

    2

    Returns: 0

  60. 2

    2

    3

    Returns: 0

  61. 2

    2

    4

    Returns: 0

  62. 2

    3

    0

    Returns: 5

  63. 2

    3

    1

    Returns: 4

  64. 2

    3

    2

    Returns: 1

  65. 2

    3

    3

    Returns: 0

  66. 2

    3

    4

    Returns: 0

  67. 3

    0

    0

    Returns: 1

  68. 3

    0

    1

    Returns: 0

  69. 3

    0

    2

    Returns: 0

  70. 3

    0

    3

    Returns: 0

  71. 3

    0

    4

    Returns: 0

  72. 3

    1

    0

    Returns: 3

  73. 3

    1

    1

    Returns: 1

  74. 3

    1

    2

    Returns: 0

  75. 3

    1

    3

    Returns: 0

  76. 3

    1

    4

    Returns: 0

  77. 3

    2

    0

    Returns: 5

  78. 3

    2

    1

    Returns: 4

  79. 3

    2

    2

    Returns: 1

  80. 3

    2

    3

    Returns: 0

  81. 3

    2

    4

    Returns: 0

  82. 3

    3

    0

    Returns: 10

  83. 3

    3

    1

    Returns: 8

  84. 3

    3

    2

    Returns: 2

  85. 3

    3

    3

    Returns: 0

  86. 3

    3

    4

    Returns: 0

  87. 0

    0

    1

    Returns: 0

  88. 0

    1

    247

    Returns: 0

  89. 0

    2

    0

    Returns: 1

  90. 0

    2

    1

    Returns: 0

  91. 0

    2

    7

    Returns: 0

  92. 0

    2

    250

    Returns: 0

  93. 0

    248

    47

    Returns: 0

  94. 0

    249

    250

    Returns: 0

  95. 0

    250

    7

    Returns: 0

  96. 1

    0

    7

    Returns: 0

  97. 1

    1

    0

    Returns: 2

  98. 1

    2

    200

    Returns: 0

  99. 1

    47

    250

    Returns: 0

  100. 1

    249

    1

    Returns: 1

  101. 1

    249

    200

    Returns: 0

  102. 1

    249

    247

    Returns: 0

  103. 1

    250

    250

    Returns: 0

  104. 2

    0

    250

    Returns: 0

  105. 2

    2

    47

    Returns: 0

  106. 2

    47

    7

    Returns: 0

  107. 2

    47

    247

    Returns: 0

  108. 2

    47

    250

    Returns: 0

  109. 2

    248

    1

    Returns: 249

  110. 2

    248

    47

    Returns: 0

  111. 2

    248

    247

    Returns: 0

  112. 2

    250

    7

    Returns: 0

  113. 2

    250

    47

    Returns: 0

  114. 47

    0

    1

    Returns: 0

  115. 47

    0

    200

    Returns: 0

  116. 47

    0

    250

    Returns: 0

  117. 47

    1

    0

    Returns: 47

  118. 47

    1

    1

    Returns: 1

  119. 47

    1

    47

    Returns: 0

  120. 47

    47

    1

    Returns: 453098367

  121. 47

    47

    250

    Returns: 0

  122. 47

    248

    0

    Returns: 460014052

  123. 47

    249

    7

    Returns: 774645520

  124. 47

    249

    200

    Returns: 0

  125. 47

    250

    0

    Returns: 906748145

  126. 47

    250

    200

    Returns: 0

  127. 248

    0

    1

    Returns: 0

  128. 248

    1

    0

    Returns: 248

  129. 248

    1

    7

    Returns: 0

  130. 248

    2

    0

    Returns: 30875

  131. 248

    2

    200

    Returns: 0

  132. 248

    47

    7

    Returns: 104902881

  133. 248

    47

    47

    Returns: 1

  134. 248

    249

    0

    Returns: 31578719

  135. 248

    249

    1

    Returns: 154036035

  136. 248

    250

    1

    Returns: 76934251

  137. 248

    250

    7

    Returns: 739465414

  138. 248

    250

    250

    Returns: 0

  139. 249

    0

    7

    Returns: 0

  140. 249

    2

    0

    Returns: 31124

  141. 249

    2

    200

    Returns: 0

  142. 249

    2

    247

    Returns: 0

  143. 249

    47

    250

    Returns: 0

  144. 249

    248

    1

    Returns: 154036035

  145. 249

    250

    0

    Returns: 217193473

  146. 250

    0

    247

    Returns: 0

  147. 250

    1

    47

    Returns: 0

  148. 250

    1

    250

    Returns: 0

  149. 250

    2

    247

    Returns: 0

  150. 250

    47

    1

    Returns: 798263612

  151. 250

    47

    200

    Returns: 0

  152. 250

    248

    7

    Returns: 739465414

  153. 250

    248

    247

    Returns: 497

  154. 250

    248

    250

    Returns: 0

  155. 250

    249

    47

    Returns: 992604047

  156. 250

    250

    47

    Returns: 985208087


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: