HDU
来源:互联网 发布:龙卷风软件 编辑:程序博客网 时间:2024/06/15 06:21
Harry And Magic Box
One day, Harry got a magical box. The box is made of n*m grids. There are sparking jewel in some grids. But the top and bottom of the box is locked by amazing magic, so Harry can’t see the inside from the top or bottom. However, four sides of the box are transparent, so Harry can see the inside from the four sides. Seeing from the left of the box, Harry finds each row is shining(it means each row has at least one jewel). And seeing from the front of the box, each column is shining(it means each column has at least one jewel). Harry wants to know how many kinds of jewel’s distribution are there in the box.And the answer may be too large, you should output the answer mod 1000000007.
There are several test cases.
For each test case,there are two integers n and m indicating the size of the box.
For each test case, just output one line that contains an integer indicating the answer.
Sample Input
1 1
2 2
2 3
Sample Output
1
7
25
#pragma comment(linker, "/STACK:1024000000,1024000000")//#include <bits/stdc++.h>#include<string>#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<queue>#include<stack>#include<vector>#include<set>#include<algorithm>#define maxn 57#define INF 0x3f3f3f3f#define eps 1e-8#define mod 1000000007#define ll long longusing namespace std;ll Pow(ll a,ll b){ a=a%mod; ll ans=1; while(b) { if(b&1) ans=ans*a%mod; a=a*a%mod; b>>=1; } return ans%mod;}ll c[maxn][maxn];void init(){ for(int i=1;i<maxn;i++) { c[i][0]=c[i][i]=1; for(int j=1;j<i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod; }}int main(){ ll n,m; init(); while(scanf("%lld%lld",&n,&m)!=EOF) { ll ans=0; for(int i=0;i<=m;i++) { if(i&1) { ans=((ans-Pow((1ll<<(m-i))-1,n)*c[m][i]%mod)%mod+mod)%mod; } else ans=((ans+Pow((1ll<<(m-i))-1,n)*c[m][i]%mod)%mod+mod)%mod; } printf("%lld\n",ans); } return 0;}
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- yii CConsoleCommand定时计划任务
- 【bzoj1592】[Usaco2008 Feb]Making the Grade 路面修整
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等,需要的朋友可以参考下。
- 【java笔试系列一】内部类、外部类和嵌套类
- 关于Git与Github的使用
- HDU
- ApsaraDB for HBase性能/延时全面领先社区版本
- base64原理
- 【19】vue.js — 父子组件
- SpringCloud Feign参数传递问题记录
- 三、Spring Cloud 的 Ribbon 负载均衡
- python cv2 中cv2.imread和cv2.resize输入输出参数顺序
- 利用wmic查看本机杀软安装情况
- 手动或主动抛出异常