一个数组的能被整除的第n个数据
class Solution {
public:
/**
* @param n a positive integer
* @param primes the given prime list
* @return the nth super ugly number
*/
int nthSuperUglyNumber(int n, vector<int>& primes) {
// Write your code here
if(n==1){
return 1;
}
int size=primes.size();
if(size==0){
return 0;
}
vector<int> res(n,INT_MAX);
res[0]=1;
vector<int> index(size,0);
for(int i=1;i<n;++i){
for(int j=0;j<size;++j){
res[i]=min(res[index[j]]*primes[j],res[i]);
}
for(int j=0;j<size;++j){
if(res[i]==res[index[j]]*primes[j]){
index[j]++;
}
}
}
return res[n-1];
}
};