Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- int y;
- int niza[100];
- int dp[10000000];
- const int MOD = 1e9 + 7;
- int c(int y1){
- if(y1==0){
- return 1;
- }
- if(dp[y1]!=-1){
- return dp[y1];
- }
- int result=0;
- for(int i=0; i<n; i++){
- if(y1-niza[i]>=0){
- result+=c(y1-niza[i]);
- result %= MOD;
- }
- }
- return dp[y1]=result;
- }
- int main()
- {
- cin>>n;
- cin>>y;
- for(int i=0; i<=y; i++){
- dp[i]=-1;
- }
- for(int i=0; i<n; i++){
- cin>>niza[i];
- }
- cout<<c(y);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement