fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. ll n,x;
  10. cin >> n >> x;
  11. vector<ll> a(n+1);
  12. for(int i=1;i<=n;i++) cin >> a[i];
  13. vector<ll> dp(N,0);
  14. sort(a.begin(),a.end());
  15. for(int i=1;i<=n;i++) dp[a[i]]=1;
  16. for(int i=1;i<N;++i){
  17. for(int j=1;j<=n;j++){
  18. if(dp[i]!=0){
  19. if(i+a[j]<N) dp[i+a[j]]+=dp[i]%Mod;
  20. }
  21. }
  22. }
  23. cout << dp[x]%Mod;
  24. }
  25.  
  26. int main(){
  27. ios::sync_with_stdio(false);
  28. cin.tie(nullptr);
  29.  
  30. /*int t;
  31.   cin >> t;
  32.   while (t--)*/ solve();
  33.  
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.02s 11100KB
stdin
3 9
2 3 5
stdout
8