Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;typedef long double llf;typedef double fl;typedef string str;typedef pair<double, double> dd;
- typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;
- typedef vector<llf> vlf;typedef vector<char> vc;typedef vector<str> vs;typedef pair<int,int> ii;
- # define f(i,a,b,c) for(ll i=a;i<b;i+=c)
- # define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
- # define w(x) while(x--)
- # define ctoi(a) (a-'0')
- # define pb push_back
- # define eb emplace_back
- # define lb lower_bound
- # define ub upper_bound
- # define be(x) x.begin(), x.end()
- # define rbe(x) x.rbegin(), x.rend()
- # define _(x) ios::sync_with_stdio(0);cin.tie(0);cout.precision(x);cout.setf(ios::fixed);
- const int MOD = 1e9+7, MAX = 100000010;
- ll n, m, coins[100], memo[MAX], confirm[MAX];
- ll dp(ll x){
- if(x<0)return 0;
- if(x==0)return 1;
- if(confirm[x])return memo[x]%MOD;
- confirm[x]=1;
- ll sum_coins=0;
- f(i,0,n,1)sum_coins+=dp(x-coins[i]);
- return memo[x]=sum_coins;
- }
- int main(){_(0)
- cin>>n>>m;
- f(i,0,n,1)cin>>coins[i];
- cout<<dp(m)%MOD<<'\n';
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement