class Solution {
public:
/*
* @param n: An integer
* @return: the nth prime number as description.
*/
int nthUglyNumber(int n) {
// write your code here
vector<int> uglyNum;
int num2=0,num3=0,num5=0;
uglyNum.push_back(1);
for(int i=1;i<n;i++){
int min1=uglyNum[num2]*2>uglyNum[num3]*3?uglyNum[num3]*3:uglyNum[num2]*2;
int min2=min1>uglyNum[num5]*5?uglyNum[num5]*5:min1;
uglyNum.push_back(min2);
cout<<min2<<endl;
if(uglyNum[i]/2==uglyNum[num2])
num2++;
if(uglyNum[i]/3==uglyNum[num3])
num3++;
if(uglyNum[i]/5==uglyNum[num5])
num5++;
}
return uglyNum.back();
}
};