标签:
import java.util.*; import java.lang.*; public class Solution { public int GetUglyNumber_Solution(int index) { if(index<7)return index; int[] dp=new int[index+1]; dp[1]=1; int mid2=1,mid3=1,mid5=1,i; for(i=2;i<index+1;i++){ dp[i]=Math.min(dp[mid2]*2,Math.min(dp[mid3]*3,dp[mid5]*5)); if(dp[mid2]*2==dp[i]) mid2++; if(dp[mid3]*3==dp[i]) mid3++; if(dp[mid5]*5==dp[i]) mid5++; } return dp[index]; } }
标签:
原文地址:http://www.cnblogs.com/tobemaster/p/5914975.html