题目链接:https://leetcode-cn.com/problems/ugly-number-ii/
题目如下:
class Solution {
public:
int nthUglyNumber(int n) {
int dp[n+1];
dp[1]=1;
int p2=1,p3=1,p5=1;
for(int i=2;i<=n;i++){
int t1=dp[p2]*2,t2=dp[p3]*3,t3=dp[p5]*5;
dp[i]=min(min(t1,t2),t3);
if(dp[i]==t1) p2++;
if(dp[i]==t2) p3++;
if(dp[i]==t3) p5++;
}
return dp[n];
}
};