cf B. Alice and the List of Presents

			B. Alice and the List of Presents
			time limit per test: 1 second
			memory limit per test: 256 megabytes
			input: standard input
			output: standard output

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 flollowing 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 (ie. 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 modulo10+ 7.
See examples and their notes for clarification.
Input
The first line contains two integers n and m, separated by spaces(1≤n, m≤10)一the number of kinds of presents and the number
of boxes that Alice has.
Output
Print one integer - 一the number of ways to pack the presents with Alice’s rules, calculated by modulo 109 + 7
题意:有n个种类的礼物,分成m份;
要求:必须包括所有的种类,同一份不会出现两种一样的种类;
思路:
1.竟然要把没种都分出去,那就一种一种的发;
2.发一种有2^m-1;
3.发n种就有(2^m -1) ^n;

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll ksm(ll a,ll b){
    ll ans=1,base=a;
    while(b){
        if(b&1) ans=ans*base%mod;
        base=base*base%mod;
        b>>=1;
    }
    return ans%mod;
}
int main(){
    ll n,m;
    cin>>n>>m;
    cout<<ksm(ksm(2,m)-1,n)%mod<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值