HDU6513 Reverse It(容斥+Cnk)

题意:http://acm.hdu.edu.cn/showproblem.php?pid=6513

你最多选两个矩阵反转,问你最后的情况数。

思路:https://www.cnblogs.com/asdfsag/p/10753244.html

很到位了。

const int N=(int)1e2+10;

char mp[N][N];
ll C(ll n,ll m) {ll ret=1; for(ll i=1; i<=m; ++i)ret=ret*(n-i+1)/i; return ret;}

signed main()
{
    int n,m;
    while(~sc("%d%d",&n,&m))
    {
        for(int i=1;i<=n;++i)sc("%s",mp[i]+1);
        n++,m++;
//        cout<<C(n,2)<<endl;
//        cout<<C(m,2)<<endl;
        ll ans=C(C(n,2)*C(m,2),2);//*C(n,2)*C(m,2)+2*C(n,2)*C(m,2);
        //ans/=2;

        ans-=C(n,2)*C(m,2)*(n+m-5);
    //    if(n>=3)ans-=C(n,2)*C(m,2)*(n+m-3);

        if(m>=4)ans-=C(n,2)*C(m,4)*2;
        if(n>=4)ans-=C(n,4)*C(m,2)*2;

        if(n>=3&&m>=3)ans-=C(n,3)*C(m,3)*8;

        if(n>=3&&m>=3)
        {
            ans-=C(n,3)*C(m,3)*4;
        }
        pr("%lld\n",ans+1);
    }
    return 0;
}

 

posted @ 2020-05-03 17:26  ZMWLxh  阅读(240)  评论(0编辑  收藏  举报