
排列組合 DP
#include<bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
//declare
const int mod = 1e9+7;
int n,x,dp[1000005];
vector<int> c;
//
signed main(){
fastio;
cin>>n>>x;
for(int i=0;i<n;i++){
int a; cin>>a;
c.push_back(a);
}
dp[0] = 1;
for(int i=1;i<=x;i++){
for(int j=0;j<n;j++){
if(i-c[j] >= 0){
dp[i] += dp[i-c[j]];
dp[i] %= mod;
}
}
}
cout<<dp[x] % mod<<"\n";
return 0;
}

發佈留言