제출 #20042

#제출 시각아이디문제언어결과실행 시간메모리
20042Namnamseo흑백 (kriii4_G)C++14
6 / 100
847 ms1084 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...