TopCoder problem "TheBasketballDivOne" used in SRM 453 (Division I Level One)



Problem Statement

    

John and Brus have an interest in team sports tournaments. They are currently investigating a basketball tournament. Basketball is a team sport in which two teams of five players try to score points against one another by placing a ball through a ten foot high hoop. Basketball is one of the most popular and widely viewed sports in the world.

There are n teams in the tournament. Each pair of teams plays exactly two games against each other. Each game results in one team winning. There are no draws. After the tournament is over, the team with the highest total number of wins takes 1st place, the team with the second highest number of wins takes 2nd place, and so on.

A sequence of integers W1, W2, ..., Wn is called a W-sequence if there exists a tournament where the team that took i-th place has exactly Wi total wins (for all i between 1 and n, inclusive). Given ints n and m, return the number of W-sequences consisting of n integers where W1 = m.

 

Definition

    
Class:TheBasketballDivOne
Method:find
Parameters:int, int
Returns:int
Method signature:int find(int n, int m)
(be sure your method is public)
    
 

Constraints

-n will be between 2 and 5, inclusive.
-m will be between 1 and 9, inclusive.
 

Examples

0)
    
2
1
Returns: 1
The only possible W-sequence is (1, 1).
1)
    
3
1
Returns: 0
There is no valid outcome where the winning team has just one win.
2)
    
3
3
Returns: 2
The two possible sequences are (3, 2, 1) and (3, 3, 0).
3)
    
4
6
Returns: 5

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10687

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13907&pm=10687

Writer:

Vasyl[alphacom]

Testers:

PabloGilberto , ivan_metelsky , Chmel_Tolstiy

Problem categories:

Search