zoukankan      html  css  js  c++  java
  • UESTC 电子科大专题训练 DP-N

    题意:有n个人写m行代码,第i个人写一行代码会产生ai个bug,问bug小于b的方案数

    思路:背包二维费用

    AC代码:

    #include "iostream"
    #include "string.h"
    #include "stack"
    #include "queue"
    #include "string"
    #include "vector"
    #include "set"
    #include "map"
    #include "algorithm"
    #include "stdio.h"
    #include "math.h"
    #define ll long long
    #define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
    #define mem(a) memset(a,0,sizeof(a))
    #define mp(x,y) make_pair(x,y)
    using namespace std;
    const long long INF = 1e18+1LL;
    const int inf = 1e9+1e8;
    const int N=1e5+100;
    
    ll n,m,b,mod,dp[505][505]={1};
    int a[505];
    int main(){
        ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
        cin>>n>>m>>b>>mod;
        for(int i=1; i<=n; ++i){
            cin>>a[i];
        }
        for(int i=1; i<=n; ++i)
            for(int k=1; k<=m; ++k){
                for(int j=a[i]; j<=b; ++j){
                    dp[k][j]=dp[k-1][j-a[i]]+dp[k][j];
                    dp[k][j]%=mod;
                }
        }
        ll ans=0;
        for(int i=0; i<=b; ++i){
            ans+=dp[m][i];
            ans%=mod;
        }
        cout<<(ans+mod)%mod<<endl;
        return 0;
    }
  • 相关阅读:
    fitnesse的安装
    elasticsearh 迁移
    网络基础之 二层三层网络通讯
    ansible 基本使用之3 palybook
    ansible-基本使用-2
    ansible 基本使用-1
    k8s 机器搭建之etcd
    http 状态码之3xx
    mysql 主从相关
    redis 主从及哨兵模式
  • 原文地址:https://www.cnblogs.com/max88888888/p/7202456.html
Copyright © 2011-2022 走看看