Statistics

Problem Statement for "HandsShaking"

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

  1. 2

    Returns: 1

    Two businessmen have only one possibility - just to shake each other's hand.

  2. 4

    Returns: 2

    Two out of three possible shakes are perfect.    

  3. 6

    Returns: 5

  4. 8

    Returns: 14

  5. 10

    Returns: 42

  6. 12

    Returns: 132

  7. 14

    Returns: 429

  8. 16

    Returns: 1430

  9. 18

    Returns: 4862

  10. 20

    Returns: 16796

  11. 22

    Returns: 58786

  12. 24

    Returns: 208012

  13. 26

    Returns: 742900

  14. 28

    Returns: 2674440

  15. 30

    Returns: 9694845

  16. 32

    Returns: 35357670

  17. 34

    Returns: 129644790

  18. 36

    Returns: 477638700

  19. 38

    Returns: 1767263190

  20. 40

    Returns: 6564120420

  21. 42

    Returns: 24466267020

  22. 44

    Returns: 91482563640

  23. 46

    Returns: 343059613650

  24. 48

    Returns: 1289904147324

  25. 50

    Returns: 4861946401452


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: