题解 | #寻找丑数#
寻找丑数
http://www.nowcoder.com/practice/cff52ae345a248ea94c8c0cc2d278474
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] ans = new int[num];
ans[0] = 1;
int a = 0, b = 0, c = 0;
for (int i = 1; i < num; i++) {
ans[i] = Math.min(ans[a] * 2, Math.min(ans[b] * 3, ans[c] * 5));
if (ans[i] == ans[a] * 2) {
a++;
}
if (ans[i] == ans[b] * 3) {
b++;
}
if(ans[i]==ans[c]*5){
c++;
}
}
System.out.print(ans[num-1]);
}
}