握手次数,每个人只握一次手

握手次数,每个人只握一次手

假设你在一个社交聚会中。如果你只握手一次,你能计算出你能做多少次握手吗?这个问题可能让你感到有趣。这个问题可以通过使用排列组合的数学方法来解决。然而,数学运算可能会耗费时间。

在本文中,我们将讨论如何使用C++解决这个问题。我们将探讨不同的方法,包括数学公式、递归和其他组合技术。

输入输出场景

Suppose you have N number of people in a gathering. You want to calculate the number of handshakes possible such that a person shakes hands only once.

Input: N = 16 Output: 120 Input: N = 11 Output: 55 登录后复制