Permutation & Combination|排列组合计算器

排列组合计算器 | Permutation & Combination Calculator

排列组合计算器 Permutation & Combination

输入 n 与 r,计算排列数 P(n,r) 与组合数 C(n,r),常见于概率与统计题。
Enter n and r to compute permutations P(n,r) and combinations C(n,r), widely used in probability and statistics.

1. 输入参数 · Inputs
n 表示“可供选择的不同元素总数”。例如:从 10 个人里选人,n=10。
n is the number of distinct items available. Example: choosing from 10 people ⇒ n=10.
r 表示“取出/安排的位置数量”。例如:选 3 个座位或抽 3 张牌,r=3。
r is the number of items selected (or the number of positions to fill).
勾选后将额外给出:可重复排列 n^r、可重复组合 C(n+r-1, r)。
When enabled: permutation with repetition n^r, and combination with repetition C(n+r-1, r).
排列 P(n,r):顺序不同算不同(例如 ABC 与 ACB 视为不同)。
组合 C(n,r):只看选了哪些,不看顺序(ABC 与 ACB 视为同一种)。
Permutation counts different orders as different outcomes; combination ignores order.
3. 使用说明 · Notes
  • 先问自己:顺序算不算? · First ask: does order matter?
    如果“顺序不同算不同”,用排列 P(n,r);如果只关心“选了哪些”,用组合 C(n,r)。
    If different orders are different outcomes, use permutation P(n,r). If order does not matter, use combination C(n,r).
    小口诀 · Quick rule: “排”看位置/顺序,“组”看集合/选人。Permutation = arrangement; Combination = selection.
  • 经典公式(不允许重复) · Classic formulas (no repetition):
    排列:P(n,r) = n × (n−1) × … × (n−r+1) = n! / (n−r)!
    组合:C(n,r) = P(n,r) / r! = n! / (r!(n−r)!)
    Tip: C(n,r) = C(n, n−r),计算时通常取较小的 r 来更快更稳。We compute using k=min(r, n−r) for stability.
  • 允许重复选取时怎么选? · What if repetition is allowed?
    若每次选完还放回(或同一元素可被重复选择),常见两种:
    ① 可重复排列:长度为 r 的序列,每个位置都有 n 种选择 ⇒ n^r。
    ② 可重复组合:从 n 类物品里取 r 个(可重复),等价“隔板法/Stars and Bars” ⇒ C(n+r−1, r)。
    If items can repeat: permutation with repetition gives n^r; combination with repetition gives C(n+r−1, r).
  • 边界与常见坑 · Edge cases & common traps:
    • 当 r=0 时:P(n,0)=1、C(n,0)=1(“什么都不选”只有 1 种方式)。When r=0, both results are 1.
    • 当 r>n 且“不允许重复”时:P(n,r)=0、C(n,r)=0(无法选够)。If r>n without repetition, results are 0.
    • 当输入不是整数:本工具会四舍五入到整数;但数学上排列组合通常只定义在整数上。Inputs are rounded to integers for convenience.
  • 概率题怎么用? · How to use in probability problems?
    很多概率题本质是 “有多少种等可能结果”。比如抽牌、排座位、分配任务:
    • 分母:所有可能情况数量(例如从 n 个里取 r 个的组合/排列)。
    • 分子:满足条件的情况数量(再用排列/组合拆分计数)。
    Most probability questions reduce to counting outcomes: Probability = favorable / total. Use P and C to count both parts correctly.

说明:本工具使用 BigInt 进行整数精确计算,适合较大的 n、r(但极大数仍会因为计算量变慢)。结果仅用于学习、练习与快速核对,不构成任何考试或统计分析结论保证。
Note: This tool uses BigInt for exact integer arithmetic. Very large inputs may be slower due to computation cost. Results are for learning and quick verification only.