如何获得数据库中一组唯一对的总数? [英] How do I get the total number of unique pairs of a set in the database?

查看:61
本文介绍了如何获得数据库中一组唯一对的总数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

4个项目:

A
B
C
D

可能有6对唯一的配对:

6 unique pairs possible:

AB
AC
AD
BC
BD
CD

如果我有100个开始物品怎么办?有多少对唯一的对?有什么公式可以输入吗?

What if I have 100 starting items? How many unique pairs are there? Is there a formula I can throw this into?

推荐答案

您要查找的是 n选择k .基本上:

What you're looking for is n choose k. Basically:

对于每100对商品,您将有4,950个组合-前提是顺序无关紧要(AB和BA被视为单个组合)并且您不想重复(AA)不是有效的货币对.

For every pair of 100 items, you'd have 4,950 combinations - provided order doesn't matter (AB and BA are considered a single combination) and you don't want to repeat (AA is not a valid pair).

这篇关于如何获得数据库中一组唯一对的总数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆