Problem Statement
There was a competition in which each of n contestants tried to score as many points as possible. Contestants who got the same number of points were tied for the same place. When announcing the results, only the places are announced (but not the points).
You are given ints n and m. Count all possible announcements of results of n contestants, and return that count modulo m.
Definition
- Class:
- CompetitionResults
- Method:
- count
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int count(int n, int m)
- (be sure your method is public)
Constraints
- n will be between 1 and 3000, inclusive.
- m will be between 2 and 10^9 + 7, inclusive.
Examples
2
1000
Returns: 3
If the two contestants are A and B, the three possible announcements are "A first, B second", "B first, A second", and "A and B tied for first".3
1000
Returns: 13
For n = 3 there are 3! = 6 possible results where no two contestants are tied, 3 possible results where two of them are tied for first place, 3 possible results where two of them are tied for second place, and one result where all three contestants have the same score. Thus, there are 6+3+3+1 = 13 possible announcements.3
10
Returns: 3
Remember that you are supposed to return the correct value modulo m.