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
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
7
0
0
Returns: 1
The home team scored seven goals in a row. There were no changes in the lead.
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
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.
6
4
2
Returns: 35
One of the 35 possibilities is the one mentioned in the problem statement.
6
7
3
Returns: 208
0
0
0
Returns: 1
The game in which nobody scores a goal has zero changes in the lead.
250
250
250
Returns: 0
0
0
1
Returns: 0
0
0
2
Returns: 0
0
0
3
Returns: 0
0
0
4
Returns: 0
0
1
0
Returns: 1
0
1
1
Returns: 0
0
1
2
Returns: 0
0
1
3
Returns: 0
0
1
4
Returns: 0
0
2
0
Returns: 1
0
2
1
Returns: 0
0
2
2
Returns: 0
0
2
3
Returns: 0
0
2
4
Returns: 0
0
3
0
Returns: 1
0
3
1
Returns: 0
0
3
2
Returns: 0
0
3
3
Returns: 0
0
3
4
Returns: 0
1
0
0
Returns: 1
1
0
1
Returns: 0
1
0
2
Returns: 0
1
0
3
Returns: 0
1
0
4
Returns: 0
1
1
0
Returns: 2
1
1
1
Returns: 0
1
1
2
Returns: 0
1
1
3
Returns: 0
1
1
4
Returns: 0
1
2
0
Returns: 2
1
2
1
Returns: 1
1
2
2
Returns: 0
1
2
3
Returns: 0
1
2
4
Returns: 0
1
3
0
Returns: 3
1
3
1
Returns: 1
1
3
2
Returns: 0
1
3
3
Returns: 0
1
3
4
Returns: 0
2
0
0
Returns: 1
2
0
1
Returns: 0
2
0
2
Returns: 0
2
0
3
Returns: 0
2
0
4
Returns: 0
2
1
0
Returns: 2
2
1
1
Returns: 1
2
1
2
Returns: 0
2
1
3
Returns: 0
2
1
4
Returns: 0
2
2
0
Returns: 4
2
2
1
Returns: 2
2
2
2
Returns: 0
2
2
3
Returns: 0
2
2
4
Returns: 0
2
3
0
Returns: 5
2
3
1
Returns: 4
2
3
2
Returns: 1
2
3
3
Returns: 0
2
3
4
Returns: 0
3
0
0
Returns: 1
3
0
1
Returns: 0
3
0
2
Returns: 0
3
0
3
Returns: 0
3
0
4
Returns: 0
3
1
0
Returns: 3
3
1
1
Returns: 1
3
1
2
Returns: 0
3
1
3
Returns: 0
3
1
4
Returns: 0
3
2
0
Returns: 5
3
2
1
Returns: 4
3
2
2
Returns: 1
3
2
3
Returns: 0
3
2
4
Returns: 0
3
3
0
Returns: 10
3
3
1
Returns: 8
3
3
2
Returns: 2
3
3
3
Returns: 0
3
3
4
Returns: 0
0
0
1
Returns: 0
0
1
247
Returns: 0
0
2
0
Returns: 1
0
2
1
Returns: 0
0
2
7
Returns: 0
0
2
250
Returns: 0
0
248
47
Returns: 0
0
249
250
Returns: 0
0
250
7
Returns: 0
1
0
7
Returns: 0
1
1
0
Returns: 2
1
2
200
Returns: 0
1
47
250
Returns: 0
1
249
1
Returns: 1
1
249
200
Returns: 0
1
249
247
Returns: 0
1
250
250
Returns: 0
2
0
250
Returns: 0
2
2
47
Returns: 0
2
47
7
Returns: 0
2
47
247
Returns: 0
2
47
250
Returns: 0
2
248
1
Returns: 249
2
248
47
Returns: 0
2
248
247
Returns: 0
2
250
7
Returns: 0
2
250
47
Returns: 0
47
0
1
Returns: 0
47
0
200
Returns: 0
47
0
250
Returns: 0
47
1
0
Returns: 47
47
1
1
Returns: 1
47
1
47
Returns: 0
47
47
1
Returns: 453098367
47
47
250
Returns: 0
47
248
0
Returns: 460014052
47
249
7
Returns: 774645520
47
249
200
Returns: 0
47
250
0
Returns: 906748145
47
250
200
Returns: 0
248
0
1
Returns: 0
248
1
0
Returns: 248
248
1
7
Returns: 0
248
2
0
Returns: 30875
248
2
200
Returns: 0
248
47
7
Returns: 104902881
248
47
47
Returns: 1
248
249
0
Returns: 31578719
248
249
1
Returns: 154036035
248
250
1
Returns: 76934251
248
250
7
Returns: 739465414
248
250
250
Returns: 0
249
0
7
Returns: 0
249
2
0
Returns: 31124
249
2
200
Returns: 0
249
2
247
Returns: 0
249
47
250
Returns: 0
249
248
1
Returns: 154036035
249
250
0
Returns: 217193473
250
0
247
Returns: 0
250
1
47
Returns: 0
250
1
250
Returns: 0
250
2
247
Returns: 0
250
47
1
Returns: 798263612
250
47
200
Returns: 0
250
248
7
Returns: 739465414
250
248
247
Returns: 497
250
248
250
Returns: 0
250
249
47
Returns: 992604047
250
250
47
Returns: 985208087