Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <list>
- #include <map>
- #include <set>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <algorithm>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #define MOD 1000000007
- using namespace std;
- class GoodSubset {
- public:
- int numberOfSubsets(int goodValue, vector <int> d) {
- map<long long, long long> buffer;
- map<long long, long long>::iterator it;
- for(int j=0;j<d.size();j++)
- {
- vector<pair<long long, long long> > toadd;
- if (goodValue % d[j] == 0) toadd.push_back(make_pair(d[j],1));
- for(it=buffer.begin();it!=buffer.end();it++)
- if(goodValue % (it->first * d[j]) == 0)
- toadd.push_back(make_pair(it->first*d[j],it->second));
- for(int k=0;k<toadd.size();k++)
- {
- buffer[toadd[k].first]=(buffer[toadd[k].first]+toadd[k].second)%MOD;
- }
- }
- return buffer[goodValue];
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement