This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
int map[5][5];
typedef long long ll;
ll ans;
const int M=int(1e9)+7;
ll pow(ll a,ll b){
if(b==0) return 1;
ll ret=pow(a,b/2);
ret=(ret*ret)%M;
if(b&1) ret=(ret*a)%M;
return ret;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
if(n>5) n=4; if(m>5) m=4;
int allm = 1<<(n*m);
int nm=1<<n, mm=1<<m;
int s;
int a,b;
for(s=0;s<allm;++s){
int i,j;
for(i=0;i<n; ++i){
for(j=0;j<m;++j){
map[i][j]=1&(s>>(i*m+j));
}
}
int a1=0, a2=0;
for(i=1;i<nm;++i){
for(j=1;j<mm;++j){
int oc, zc;
zc=oc=0;
for(a=0; a<n; ++a) if(1&(i>>a))
for(b=0; b<m; ++b) if(1&(j>>b)){
if(map[a][b]==1) ++oc;
else ++zc;
}
if(zc==0) ++a1;
if(oc==0) ++a2;
}
}
ans += a1*1LL*a2;
}
printf("%d\n",int(ans*pow(1<<(n*m),M-2)%M));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |