标签:int str main ble long return c++ and end
Link
题意:
\(n\) 种礼物分配给 \(m\) 个盒子
每种礼物有无限个,每个盒子至多拥有同种礼物一个并保证每种礼物至少被分配一次
思路:
求组合数
\(present_1\) 总共 \(2^{m-1}\) 种分法
根据乘法原理 \(n\) 个 \(present\) 共有 \({2^{m-1}}^n\) 种分法
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n,m;
ll ksm(ll n,ll x)
{
ll res=1;
while(x)
{
if(x&1) res=res*n%mod;
n=n*n%mod;
x>>=1;
}
return res;
}
int main()
{
cin>>n>>m;
cout<<ksm((ksm(2,m)+mod-1)%mod,n)<<endl;
return 0;
}
Codeforces Round #593 (Div. 2) B. Alice and the List of Presents
标签:int str main ble long return c++ and end
原文地址:https://www.cnblogs.com/c4Lnn/p/12398362.html