CF1236B.Alice and the List of Presents
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.
There are n kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.
Also, there are m boxes. All of them are for different people, so they are pairwise distinct (consider that the names of m friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.
Alice wants to pack presents with the following rules:
- She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of n kinds, empty boxes are allowed);
- For each kind at least one present should be packed into some box.
Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo 109+7.
See examples and their notes for clarification.
最近,Alice 收到了许多礼物。因此她决定将这些礼物装进盒子,并寄送给她的朋友们。
共有 n 种不同的礼物。同一种类的礼物彼此完全相同(即无法区分两个同种类的礼物);不同种类的礼物则互不相同(即两个不同种类的礼物可被区分)。每种礼物 Alice 拥有的数量都非常多,因此我们可以认为 Alice 每种礼物均有无限多个。
此外,共有 m 个盒子。这些盒子是为不同的人准备的,因此彼此互异(例如,可以理解为 m 位朋友的名字已分别写在各个盒子上)。举例来说,将第一种礼物放入第一个盒子但不放入第二个盒子,与将第一种礼物放入第二个盒子但不放入第一个盒子,这两种情况被视为不同。
Alice 希望按如下规则装箱:
- 每个盒子中,同一种类的礼物至多放入一个,即每个盒子中所含礼物的种类互不相同(换言之,每个盒子对应 n 种礼物的一个子集;允许存在空盒子);
- 对于每一种礼物,至少有一个该种类的礼物被装入某个盒子中。
现在 Alice 想知道:满足上述条件的装箱方案总数有多少?请你帮她计算这个数目。由于答案可能非常大,请对 109+7 取模后输出。
参见样例及其说明以进一步理解。
输入格式
The first line contains two integers n and m, separated by spaces (1≤n,m≤109) — the number of kinds of presents and the number of boxes that Alice has.
第一行包含两个整数 n 和 m,以空格分隔(1≤n,m≤109)——分别表示礼物的种类数和爱丽丝拥有的盒子数。
输出格式
Print one integer — the number of ways to pack the presents with Alice's rules, calculated by modulo 109+7
输出一个整数——在爱丽丝的规则下包装礼物的方法数,结果对 109+7 取模。
输入输出样例
输入#1
1 3
输出#1
7
输入#2
2 2
输出#2
9
说明/提示
In the first example, there are seven ways to pack presents:
1
1
1
11
11
11
111
In the second example there are nine ways to pack presents:
1,2
12
11,2
21
21,2
1,2
1,21
1,22
1,21,2
For example, the way 22 is wrong, because presents of the first kind should be used in the least one box.
在第一个例子中,共有七种包装礼物的方式:
1
1
1
11
11
11
111
在第二个例子中,共有九种包装礼物的方式:
1,2
12
11,2
21
21,2
1,2
1,21
1,22
1,21,2
例如,方式 22 是错误的,因为第一种礼物至少需使用在一个盒子中。
输入解题思路,AI测评打分。不知道怎么写?