UESTC 电子科大专题训练 DP-N
生活随笔
收集整理的這篇文章主要介紹了
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; }?
轉載于:https://www.cnblogs.com/max88888888/p/7202456.html
總結
以上是生活随笔為你收集整理的UESTC 电子科大专题训练 DP-N的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 杭电 1233 最小生成树 kruska
- 下一篇: cad编辑节点快捷键是什么_cad201