gpt4 book ai didi

在 C 中创建 n 项的所有可能的 k 和 m 组合子集

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:19:44 24 4
gpt4 key购买 nike

<分区>

我正在为我的问题寻找解决方案:我必须编写一个代码来计算唯一元素的组合,即选择为组的 n 个元素的所有不同组合k 个元素并重新计算剩余子集的新组合而不进行复制。给定 S,所有可能的唯一元素的集合,我必须计算 S 的元素的唯一组合的子集 T,现在我有重新计算 T 的组合的新子集 - V - 所有子集 T 和 V 必须是唯一的:

For example I have this set S: {0, 1, 2, 3, 4}

我必须得到

a {0, 1} {2, 3} { 4} 
b {0, 1} {2, 4} { 3}
c {0, 1} {3, 4} { 2}
d {0, 2} {1, 3} { 4}
e {0, 2} {1, 4} { 3}
f {0, 2} {3, 4} { 1}
g {0, 3} {1, 2} { 4}
h {0, 3} {1, 4} { 2}
i {0, 3} {2, 4} { 1}
j {0, 4} {1, 2} { 3}
k {0, 4} {1, 3} { 2}
l {0, 4} {2, 3} { 1}
discarded as the same as g -> {1, 2} {0, 3} { 4}
discarded as the same as j -> {1, 2} {0, 4} { 3}
m {1, 2} {3, 4} {0}
discarded as the same as d -> {1, 3} {0, 2} { 4}
discarded as the same as k -> {1, 3} {0, 4} { 2}
n {1, 3} {2, 4}{ 0}
discarded as the same as e -> {1, 4} {0, 2} { 3}
discarded as the same as h -> {1, 4} {0, 3} { 2}
o {1, 4} {2, 3}{0}
discarded as the same as a -> {2, 3} {0, 1} { 4}
discarded as the same as l -> {2, 3} {0, 4} { 1}
discarded as the same as o -> {2, 3} {1, 4} { 0}
discarded as the same as b -> {2, 4} {0, 1} { 3}
discarded as the same as i -> {2, 4} {0, 3} { 1}
discarded as the same as n -> {2, 4} {1, 3} { 0}
discarded as the same as c -> {3, 4} {0, 1} { 2}
discarded as the same as f -> {3, 4} {0, 2} { 1}
discarded as the same as m -> {3, 4} {1, 2} { 0}

组合{1, 2} {0, 3} { 4} 与(对于本题)的 {0, 3} {1, 2} { 4} 相同,然后必须丢弃,与 {1, 2} 相同{0, 4} { 3} 和 {0, 4} {1, 2} { 3}。

是否可以在不使用考虑已获得组合的数据结构(如列表)的情况下实现目标?

我需要这样的东西:Generating Combinations: 1

这不是上一个问题的重复,因为研究涉及必须被认为是单一的分区,即其中包含的元素(无论它们的顺序如何)在之前的 segmentation 中一定不是已经达成共识的,例如 {1 , 2} {0, 4} { 3} 和 {0, 4} {1, 2} { 3} 必须被认为是非唯一的,因此只有组合有效:{0, 4} {1, 2} {3}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com