using System;
using System.Collections.Generic;


class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param index int整型
     * @return int整型
     */
    public int GetUglyNumber_Solution(int index) {
        // write code here
        if (index == 0)
            return 0;
        List<int> listN = new List<int>() {
            1
        };
        int nIndex2 = 0, nIndex3 = 0, nIndex5 = 0;
        while (listN.Count < index) {
            int nNew2 = listN[nIndex2] * 2;
            int nNew3 = listN[nIndex3] * 3;
            int nNew5 = listN[nIndex5] * 5;
            int nNewMin = Math.Min(nNew2, Math.Min(nNew3, nNew5));
            listN.Add(nNewMin);
            if (nNewMin == nNew2) nIndex2++;
            if (nNewMin == nNew3) nIndex3++;
            if (nNewMin == nNew5) nIndex5++;
        }
        return listN[index - 1];
    }
}