• tyvj4541 zhx 提高组P1


    背景

    提高组

    描述

    在一个N×M的棋盘上,要求放置K个车,使得不存在一个车同时能被两个车攻击。问方案数。

    输入格式

    一行三个整数,N,M,K。

    输出格式

    一行一个整数,代表答案对1000001取模之后的值。

    备注

    【样例输入1】
    4 5 2
    【样例输出1】
    190
    【样例输入2】
    2 3 3
    【样例输出2】
    6
    【样例输入3】
    6 7 20
    【样例输出3】
    0
    【样例输入4】
    23 37 39
    【样例输出4】
    288688
    【样例解释】
    【数据规模与约定】
    对于100%的数据,1≤N,M≤50,1≤K≤100。

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int maxn = 55,mod = 1000001;
    int n,m,k,f[2][maxn<<1][maxn<<1][maxn<<1],ans,cnt;
    int main(){
        cin>>n>>m>>k;
        f[0][0][0][0] = 1;
        for(int i = 1;i <= n;i++){
            cnt ^= 1;
            for(int j = 0;j <= n<<1;j++){
                for(int l = 0;l <= n<<1;l+=2){
                    for(int p = 0;p <= n;p++){
                        f[cnt][j][l][p] = f[cnt^1][j][l][p];
                        if(j > 0) f[cnt][j][l][p] += f[cnt^1][j-1][l][p]*(m-j-p-l+1);
                        if(p > 0) f[cnt][j][l][p] += f[cnt^1][j+1][l][p-1]*(j+1);
                        if(l > 1) f[cnt][j][l][p] += (f[cnt^1][j][l-2][p]*(m-j-l-p+2)*(m-j-l-p+1))>>1;
                        f[cnt][j][l][p] %= mod;
                        if(i == n && j + l + (p<<1) == k){
                            ans = (ans + f[cnt][j][l][p]) % mod;
                        }
                    }
                }
            }
        }
        cout<<ans;
        return 0;
    } 
  • 相关阅读:
    .NET Core 服务调用 RPC
    从Docker 到 Kubernatetes 的跃迁之路
    同步异步-多线程梳理
    Net的微服务选型之路
    Visual Studio 2019安装SSIS
    HL7协议的基本语法
    vue学习笔记
    开发常用的部分sql语句总结
    VSPD虚拟串口来调试通信接口程序
    SSRS报表工具之合并行数据
  • 原文地址:https://www.cnblogs.com/hyfer/p/5689440.html
Copyright © 2020-2023  润新知