TopCoder problem "HandsShaking" used in SRM 363 (Division I Level One , Division II Level Two)



Problem Statement

    Consider a meeting of n businessmen sitting around a circular table. To start the meeting, they must shake hands. Each businessman shakes the hand of exactly one other businessman. All handshakes happen simultaneously. We say that the shake is perfect if no arms cross each other. Given an int n, return the number of perfect shakes that exist for n businessmen. See examples for further clarification.
 

Definition

    
Class:HandsShaking
Method:countPerfect
Parameters:int
Returns:long
Method signature:long countPerfect(int n)
(be sure your method is public)
    
 

Notes

-Businessmen are distinguishable. Rotating a perfect shake can yield a different perfect shake (see example 1).
 

Constraints

-n will be between 2 and 50, inclusive.
-n will be even.
 

Examples

0)
    
2
Returns: 1
Two businessmen have only one possibility - just to shake each other's hand.
1)
    
4
Returns: 2
Two out of three possible shakes are perfect.



   
2)
    
8
Returns: 14

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10777&pm=7868

Writer:

mateuszek

Testers:

PabloGilberto , Olexiy , lovro , ivan_metelsky

Problem categories:

Advanced Math, Dynamic Programming