Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is a subset of S, (1 <= i <= k))
The input contains multiple cases, each case have 2 integers in one line represent n and k(1 <= k <= n <= 231-1), proceed to the end of the file.
Output the total number mod 1000000007.
1 1 2 2
1 9
整套比赛最简单的一个。
可以直接写一个暴力程序,然后找规律。
规律很显然的~
我的代码:
#include<stdio.h> #include<iostream> using namespace std; typedef long long ll; ll mod=1000000007; ll power(ll p,ll n,ll m) { ll sq=1; while(n>0) { if(n%2==1) sq=(sq%m)*(p%m)%m; p=(p%m)*(p%m)%m; n=n/2; } return sq%m; } int main() { ll n,k,ans; while(cin>>n>>k) { ans=power(2,k,mod)-1; ans=power(ans,n,mod); cout<<ans<<endl; } return 0; }