Rosalind第45题:Counting Subsets

Problem

set is the mathematical term for a loose collection of objects, called elements. Examples of sets include  and , the set containing all real numbers. We even have the empty set, represented by  or , which contains no elements at all. Two sets are equal when they contain the same elements. In other words, in contrast to permutations, the ordering of the elements of a set is unimportant (e.g.,  is equivalent to ). Sets are not allowed to contain duplicate elements, so that  is not a set. We have already used sets of 2 elements to represent edges from a graph.

A set  is a subset of  if every element of  is also an element of , and we write . For example, , and  is a subset of every set (including itself!).

As illustrated in the biological introduction, we can use subsets to represent the collection of taxa possessing a character. However, the number of applications is endless; for example, an event in probability can now be defined as a subset of the set containing all possible outcomes.

Our first question is to count the total number of possible subsets of a given set.

Given: A positive integer  ().

Return: The total number of subsets of  modulo 1,000,000.

是对象的松散集合,称为数学术语元素。集的示例包括和,包含所有实数的集。我们甚至有一个空集,用或表示,它根本不包含任何元素。当两组包含相同元素时,它们是相等的。换句话说,与排列相反,集合中元素的顺序并不重要(例如等效于 )。集合不允许包含重复元素,因此不是集合。我们已经使用组2个元件的代表边缘从一个曲线图

一组是一个子集的,如果的每个元素也是一个元素,我们写。例如,和是每个集合(包括它本身!)的子集。

如生物学介绍中所示,我们可以使用子集来表示具有特征的分类单元的集合。但是,申请的数量是无限的。例如,一个事件概率现在可以定义为包含所有可能的集合的子集的结果

我们的第一个问题是计算给定集合的可能子集的总数。

给定:正整数()。

返回值:模数为1,000,000的子集总数。

 

Sample Dataset

3

Sample Output

8

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值